here some code that i working on
- User
here some code that i working on
- Assistant
Of course! Please go ahead and share the code you're working on, and let me know how I can assist you. Whether you have specific questions or need help troubleshooting, I'll do my best to help.
- User
namespace SchedulingTool.BusinessModel.Commands.Base;
public abstract class ManageResourceCommandBase<Input, Result> : FunctionalUserCommand<Input, Result> {
public IIdentity SaveResource(Resource resource , string path) { ResourceType type = resource.Type; resource.CreateDate = DateTime.Now; resource.CreatedBy = _Username; var _resourceTypeRepository = new ResourceTypeRepository(); var validType = _resourceTypeRepository.GetResourceTypeByName(type.ToString()); if (validType == null) { validType = new ResourceType { Name = type.ToString() }; _resourceTypeRepository.AddResourceType(validType); } resource.Type = validType; IIdentity resourcePath = _UserContext.Bin("Schedule").SelectPath(path, false); if (resourcePath == null) { IIdentity resourceSourcePath = _UserContext.Bin("Schedule").SelectPath("Resources"); string name = type + "s"; resourcePath = resourceSourcePath.Composes(new GeneralEntity() { Name = name }, name, Gam.Lexical.Concepts.GeneralConcepts.Taxonomy); } IIdentity newResource = resourcePath.Composes(resource, resource.Name, Gam.Lexical.Concepts.GeneralConcepts.Resource); return newResource; } public IIdentity UpdateResource(Resource resource,Guid id) { resource.LastModificationDate = DateTime.Now; resource.LastModifiedBy = _Username; IIdentity identity = _UserContext.IdentityById(id); identity.Update(resource); identity.Commit(); return identity; } - Assistant
Your code defines an abstract class
ManageResourceCommandBasein theSchedulingTool.BusinessModel.Commands.Basenamespace, extending a classFunctionalUserCommand. This class provides the methods and for managing resources, presumably in some kind of scheduling or resource management system. Here are some general observations and suggestions for improvement: - User
ok. here I get this error : { "CDT": "2024-10-07T08:55:58.93939+03:30", "Duration": 16, "EDT": "2024-10-07T08:55:58.9562045+03:30", "Output": null, "StateCode": 4, "StateName": "NoPermit", "Description": "Type value is not valid" }
- Assistant
- User
does this code have any pattern problem? using Gam.General.Structures; using Gam.IAM; using SchedulingTool.BusinessModel.Commands.Base; using SchedulingTool.BusinessModel.Helpers; using SchedulingTool.ContentModel.Base;
namespace SchedulingTool.BusinessModel.Commands.ResourceManagement.Resources.CreateSimulatorRoomCommand;
public class CreateSimulatorRoomCommand : ManageResourceCommandBase<CreateSimulatorRoomCommandArgs, CreateSimulatorRoomCommandOutput> { protected override bool CanRun(CreateSimulatorRoomCommandArgs args) { if (!args.editMode.Value) { Result.Description = "Type value is not valid"; return false; } else if (args.editMode.Value && args.Id == Guid.Empty ) { Result.Description = "resource id is required"; return false; } return true; }
- Assistant
- User
i wanna send you more classes of my project, then I will ask you some questions. ok?
- Assistant
Absolutely! Feel free to share more classes from your project, and I'll do my best to help you with any questions or issues you may have.
- User
using Gam.Lexical.Concepts;
namespace SchedulingTool.ContentModel.Base { [QueryField] public class ResourceType { public string Name { get; set; } public ResourceCategory? Category { get; set; } }
public interface IResourceTypeRepository { void AddResourceType(ResourceType resourceType); ResourceType GetResourceTypeByName(string name); } public class ResourceTypeRepository : IResourceTypeRepository { private readonly List<ResourceType> _resourceTypes; public ResourceTypeRepository() { _resourceTypes = new List<ResourceType>(); } public void AddResourceType(ResourceType resourceType) { _resourceTypes.Add(resourceType); // Save to the graph db Console.WriteLine($"ResourceType {resourceType.Name} added."); } public ResourceType GetResourceTypeByName(string name) { return _resourceTypes.FirstOrDefault(rt => rt.Name == name); } }}
- Assistant
- User
using Gam.Lexical.Concepts;
namespace SchedulingTool.ContentModel.Base { [QueryField] public class Resource : SchedulingEntityModelBase { public string Name { get; set; } public ResourceType Type { get; set; }
} public interface IResourceRepository { void AddResource(Resource resource); Resource GetResourceById(int id); }}
- Assistant
- User
using SchedulingTool.ContentModel.Base;
namespace SchedulingTool.BusinessModel.Commands.ResourceManagement.Resources.CreateSimulatorRoomCommand;
public class CreateSimulatorRoomCommandArgs : SimulatorRoom {
}
- Assistant
- User
using Gam.Foundation.Business; using Gam.IAM; using Gam.Lexical.Concepts; using SchedulingTool.ContentModel.Base;
namespace SchedulingTool.BusinessModel.Commands.ResourceManagement.Resources.CreateSimulatorRoomCommand;
public class CreateSimulatorRoomCommandOutput { public Guid Id { get; set; } public string? ResultStatus { get; set; } }
- Assistant
- User
ok I just send you my classes. now my question: I run createsimulatorroom method with this data: msg://{ "Performative": "REQUEST", "Language": "ACL", "Ontology": "*", "Sender": "ws8283@client", "Receiver": "mp@Master", "Protocol": "createsimulatorroom", "Content": { "Args": { "Capacity": 0, "Name": "sim room 1", "Type": { "Name": "Room", "Category": null }, "Id": "00000000-0000-0000-0000-000000000000", "CreateDate": null, "CreatedBy": null, "LastModificationDate": null, "LastModifiedBy": null, "Revision": null, "editMode": false, "Properties": [] } }, "ReplyWith": "ProcessResponse" }
- Assistant
- User
why i got this error? { "CDT": "2024-10-07T09:03:51.0409062+03:30", "Duration": 0, "EDT": "2024-10-07T09:03:51.0415357+03:30", "Output": null, "StateCode": 4, "StateName": "NoPermit", "Description": "Type value is not valid" }
- Assistant