public IActionResult CreateEntity() { CreateEntityModel model = new CreateEntityModel { EntityMask = EntityMaskEnum.User, SolutionId = SolutionId.Value }; return(View($"~/Areas/{WebContext.Area}/Views/Entity/{WebContext.ActionName}.cshtml", model)); }
public IActionResult CreateEntity(CreateEntityModel model) { if (ModelState.IsValid) { model.Name = model.Name.Trim(); var entity = new Schema.Domain.Entity(); model.CopyTo(entity); entity.EntityId = Guid.NewGuid(); entity.IsCustomizable = true; entity.CreatedBy = CurrentUser.SystemUserId; entity.OrganizationId = CurrentUser.OrganizationId; if (model.EntityGroupId.NotEmpty()) { entity.EntityGroups = model.EntityGroupId.SerializeToJson(); } if (_entityCreater.Create(entity, model.DefaultAttributes)) { //创建默认按钮 if (model.DefaultButtons.NotEmpty()) { _eventPublisher.Publish(new CreateDefaultButtonsEvent(entity, model.DefaultButtons)); } //创建默认表单 if (model.CreateDefaultForm) { _eventPublisher.Publish(new CreateDefaultFormEvent(entity)); } //创建默认视图 if (model.CreateDefaultView) { _eventPublisher.Publish(new CreateDefaultViewEvent(entity)); } return(CreateSuccess(new { id = entity.EntityId })); } return(CreateFailure()); } return(CreateFailure(GetModelErrors())); }
public IActionResult Post(CreateEntityModel model) { if (ModelState.IsValid) { if (_entityFinder.FindByName(model.Name) != null) { return(JError(T["name_already_exists"])); } model.Name = model.Name.Trim(); var entity = new Schema.Domain.Entity(); model.CopyTo(entity); entity.SolutionId = _solutionId.Value; entity.IsCustomizable = true; entity.EntityId = Guid.NewGuid(); entity.CreatedBy = CurrentUser.SystemUserId; entity.CreatedOn = DateTime.Now; entity.OrganizationId = CurrentUser.OrganizationId; _entityCreater.Create(entity); return(CreateSuccess(new { id = entity.EntityId })); } return(CreateFailure(GetModelErrors())); }
public ResponseWrapper <CreateEntityModel> CreateEntity(CreateEntityInputModel model) { var newEntity = new Entity { Name = model.Name, PluralName = model.PluralName, SchemaId = model.SchemaId, }; context .Entities .Add(newEntity); context.SaveChanges(); var response = new CreateEntityModel { EntityId = newEntity.EntityId, Name = newEntity.Name, PluralName = newEntity.PluralName, SchemaId = newEntity.SchemaId, }; return(new ResponseWrapper <CreateEntityModel>(_validationDictionary, response)); }
public ActionResult Create(CreateEntityModel model) { return(View()); }