public static async Task <string> DeleteAppTypeValidation(AppTypeModel model, MetadataDbContext dbContext) { if (await dbContext.AppInstances.AnyAsync(x => x.AppTypeId == model.Id)) { return("This app type is refered to one or more app instances."); } if (await dbContext.EntityTypes.AnyAsync(x => x.AppTypeId == model.Id)) { return("This app type is refered to one or more entities."); } return(await Task.FromResult(string.Empty)); }
public async Task <ActionResult> DeleteAppType(AppTypeModel model) { var validationMessage = await AppManagementValidationLogic.DeleteAppTypeValidation(model, _dbContext); if (!string.IsNullOrEmpty(validationMessage)) { return(StatusCode(400, validationMessage)); } var appType = await _dbContext.AppTypes.FindAsync(model.Id); _dbContext.AppTypes.Remove(appType); await _dbContext.SaveChangesAsync(); ((RequestLogModel)HttpContext.Items["RequestLog"]).AppTypeId = appType.Id; return(Ok()); }
public async Task <ActionResult> AddAppType(AppTypeModel model) { var validationMessage = await AppManagementValidationLogic.AddAppTypeValidation(model, _dbContext); if (!string.IsNullOrEmpty(validationMessage)) { return(StatusCode(400, validationMessage)); } var appType = new AppType { Title = model.Title, Name = model.Name, Id = model.Id }; _dbContext.AppTypes.Add(appType); await _dbContext.SaveChangesAsync(); ((RequestLogModel)HttpContext.Items["RequestLog"]).AppTypeId = appType.Id; return(Ok()); }
public static async Task <string> EditAppTypeValidation(AppTypeModel model, MetadataDbContext dbContext) { return(await Task.FromResult(string.Empty)); }