public static Response ValidateEntity(EntityAddEditModel entity, Response response = null) { response = response ?? new Response(); if (string.IsNullOrEmpty(entity.Name)) { response.AddMessage(false, "The name should not be empty", ResponseMessageType.Warning); } if (entity.TypeId == 0) { response.AddMessage(false, "Select an Entity Type", ResponseMessageType.Warning); } return(response); }
public static async Task <Utils.Messages.Response> EditEntityAsync(EntityAddEditModel entityModel) { var response = new Response(); var context = new AdminDbContext(); ValidateEntity(entityModel, response); if (!response.Success) { return(response); } var entity = context.Entities.Find(entityModel.Id); entity.TypeId = entityModel.TypeId; entity.Name = entityModel.Name; await context.SaveChangesAsync(); return(response); }
public async Task <JsonResult> AddEntity(EntityAddEditModel entity) { Quince.Utils.Messages.Response response = await EntityManager.AddEntityAsync(entity); return(Json(response)); }