public async Task <AddResult> AddRecord(string name) { TransportCategoryEntity transportCategoryEntity = new TransportCategoryEntity { Name = name }; await dbContext.TransportCategories.AddAsync(transportCategoryEntity); await dbContext.SaveChangesAsync(); if (await dbContext.TransportCategories.AnyAsync(tc => tc.Id == transportCategoryEntity.Id)) { return(AddResult.Success); } return(AddResult.Failed); }
public async Task <DeleteResult> DeleteRecord(int recordId) { TransportCategoryEntity transportCategoryEntity = await dbContext.TransportCategories.FirstOrDefaultAsync(a => a.Id == recordId); if (transportCategoryEntity == null) { return(DeleteResult.RecordNotFound); } dbContext.TransportCategories.Remove(transportCategoryEntity); await dbContext.SaveChangesAsync(); if (!await dbContext.TransportCategories.AnyAsync(a => a.Id == transportCategoryEntity.Id)) { return(DeleteResult.Success); } return(DeleteResult.Failed); }