private void CreateDateAttributes(GenericManager genericManager) { var createdOnProperty = new Property() { Name = "CreatedOn", Type = new OptionSetValue((int)Property.PropertyType.DateTime), SchemaId = SchemaEntityReference }; var modifiedOnProperty = new Property() { Name = "ModifiedOn", Type = new OptionSetValue((int)Property.PropertyType.DateTime), SchemaId = SchemaEntityReference }; genericManager.Create(Property.LogicalName, Entity.EntityToDictionary(createdOnProperty)); genericManager.Create(Property.LogicalName, Entity.EntityToDictionary(modifiedOnProperty)); CreateDefaultViewRepositoryMethod(genericManager, "GetByCreatedOnAtYear", new MethodParameter[] { new MethodParameter() { Name = "Year", Type = MethodParameter.ParameterInputType.Integer } }); //TODO other methods }
private Guid CreateRepositoryMethod( GenericManager genericManager, string methodName, RepositoryMethod.RepositoryMethodType type, MethodParameter[] inputParameters, MethodParameter outputParameter) { var content = new RepositoryMethodContent(); foreach (var item in inputParameters) { item.Direction = MethodParameter.ParameterDirection.Input; } if (outputParameter != null) { outputParameter.Direction = MethodParameter.ParameterDirection.Output; content.Parameters.Add(outputParameter); } content.Parameters.AddRange(inputParameters); var method = new RepositoryMethod() { Name = methodName, RepositoryId = RepositoryEntityReference, Type = new OptionSetValue((int)type), Content = JsonParserService.StringfyWithTypes(content), }; return(genericManager.Create(RepositoryMethod.LogicalName, Entity.EntityToDictionary(method))); }
private Guid CreateMainRepository(GenericManager genericManager, string repositoryName) { var repo = new Repository() { IsMainRepository = true, Name = repositoryName, SchemaId = SchemaEntityReference }; return(genericManager.Create(Repository.LogicalName, Entity.EntityToDictionary(repo))); }
private void CreateMainModel(GenericManager manager, string name) { var model = new Model() { AllProperties = true, SchemaId = SchemaEntityReference, IsMainModel = true, Name = name, }; manager.Create(Model.LogicalName, Entity.EntityToDictionary(model)); }
private void CreateIdAttribute(GenericManager genericManager) { var idProperty = new Property() { IsPrimaryKey = true, Name = "Id", Type = new OptionSetValue((int)Property.PropertyType.PrimaryKey), SchemaId = SchemaEntityReference }; genericManager.Create(Property.LogicalName, Entity.EntityToDictionary(idProperty)); }
private void CreateNameAttribute(GenericManager genericManager) { var nameProperty = new Property() { Length = 200, Name = "Name", Type = new OptionSetValue((int)Property.PropertyType.String), SchemaId = SchemaEntityReference }; genericManager.Create(Property.LogicalName, Entity.EntityToDictionary(nameProperty)); }
private void CreateStateAttributes(GenericManager genericManager) { var stateProperty = new Property() { Name = "State", Type = new OptionSetValue((int)Property.PropertyType.State), SchemaId = SchemaEntityReference }; var statusProperty = new Property() { Name = "Status", Type = new OptionSetValue((int)Property.PropertyType.Status), SchemaId = SchemaEntityReference }; genericManager.Create(Property.LogicalName, Entity.EntityToDictionary(stateProperty)); genericManager.Create(Property.LogicalName, Entity.EntityToDictionary(statusProperty)); _ = CreateDefaultZeroInputsViewRepositoryMethod(genericManager, "GetActive"); _ = CreateDefaultZeroInputsViewRepositoryMethod(genericManager, "GetInactive"); }
private Guid CreateDefaultZeroInputsViewRepositoryMethod(GenericManager genericManager, string methodName) { var content = new RepositoryMethodContent() .AddDefaultOutputViewParameter(); var method = new RepositoryMethod() { Name = methodName, Type = new OptionSetValue((int)RepositoryMethod.RepositoryMethodType.View), RepositoryId = RepositoryEntityReference, Content = JsonParserService.StringfyWithTypes(content), }; return(genericManager.Create(RepositoryMethod.LogicalName, Entity.EntityToDictionary(method))); }
private Guid CreateUseCase(GenericManager manager, string name, string displayName, string description, UseCaseType type, UseCaseContent content) { var usecase = new UseCase() { SchemaId = SchemaEntityReference, Name = name, Description = description, DisplayName = displayName, Type = new OptionSetValue((int)type), Content = JsonParserService.StringfyWithTypes(content), }; return(manager.Create(UseCase.LogicalName, Entity.EntityToDictionary(usecase))); }
private void CreateUserAttributes(GenericManager manager) { var createdByProperty = new Property() { Name = "CreatedBy", Type = new OptionSetValue((int)Property.PropertyType.EntityReference), SchemaId = SchemaEntityReference }; manager.Create(Property.LogicalName, Entity.EntityToDictionary(createdByProperty)); var modifiedByProperty = new Property() { Name = "ModifiedBy", Type = new OptionSetValue((int)Property.PropertyType.EntityReference), SchemaId = SchemaEntityReference }; manager.Create(Property.LogicalName, Entity.EntityToDictionary(createdByProperty)); manager.Create(Property.LogicalName, Entity.EntityToDictionary(modifiedByProperty)); CreateDefaultViewRepositoryMethod(manager, "GetByCreatedBy", new MethodParameter[] { new MethodParameter() { Name = "Id", Type = MethodParameter.ParameterInputType.Guid } }); CreateDefaultViewRepositoryMethod(manager, "GetByModifiedBy", new MethodParameter[] { new MethodParameter() { Name = "Id", Type = MethodParameter.ParameterInputType.Guid, } }); }
private void CreateOwnerAttribute(GenericManager manager) { var ownerProperty = new Property() { Name = "Owner", Type = new OptionSetValue((int)Property.PropertyType.EntityReference), SchemaId = SchemaEntityReference, }; manager.Create(Property.LogicalName, Entity.EntityToDictionary(ownerProperty)); CreateDefaultViewRepositoryMethod(manager, "GetByOwner", new MethodParameter[] { new MethodParameter() { Name = "Id", Type = MethodParameter.ParameterInputType.Guid } }); }
private void InitializeCommands() { SaveCommand = new RelayCommand((data) => { if (Mode == DetailMode.Creating) { var id = GenericManager.Create(Entity.LogicalName, Values); var newData = GenericManager.Retrieve(Entity.LogicalName, id); Id = id; Values = newData.Values; Mode = DetailMode.Updating; BusinessEventManager.RaiseOnCreatedEntity(Entity, newData.Values); } else if (Mode == DetailMode.Updating) { GenericManager.Update(Entity.LogicalName, Id, Values); BusinessEventManager.RaiseOnUpdatedEntity(Entity, Id, Values); } }, (data) => { return(IsCompleted); }); DeleteCommand = new RelayCommand((data) => { var dialog = new OkCancelMessageBox("Confirm the delete? This operation cannot be undone", "Delete operation"); dialog.ShowDialog(); if (dialog.Response == OkCancelMessageBox.InputTextBoxResponse.OK) { GenericManager.Delete(Entity.LogicalName, Id); BusinessEventManager.RaiseOnDeletedEntity(Entity, Id); } }, (data) => { return(Mode == DetailMode.Updating); }); RegisterCommand(SaveCommand); RegisterCommand(DeleteCommand); }