public async Task DeletePosReason(int id) { var posReason = await _repository.FindAsync <PosReason>(id); if (posReason != null) { await _repository.DeleteAsync(posReason); } }
public async Task DeleteAppTriageFile(int fileId) { var file = await _repository.FindAsync <AppTriageFile>(fileId); if (file != null) { await _repository.DeleteAsync(file); } }
public async Task SaveAdmManagementLevels(IEnumerable <AdmManagementLevelSaveModel> requestItems) { var existingIds = new List <int>(); foreach (var item in requestItems) { //update if (item.AdmManagementLevelID != 0) { existingIds.Add(item.AdmManagementLevelID); var existingAdmManagementLevel = await _repository.FindAsync <AdmManagementLevel>(item.AdmManagementLevelID); if (existingAdmManagementLevel != null) { existingAdmManagementLevel.Description = item.Description; existingAdmManagementLevel.ManagementLevelOrder = item.ManagementLevelOrder; await _repository.UpdateAsync(existingAdmManagementLevel); } } //insert else { var newAdmManagementLevel = _autoMapper.Map <AdmManagementLevel>(item); await _repository.CreateAsync(newAdmManagementLevel); } } //delete var deletedItems = await _repository.GetListAsync <AdmManagementLevel>(x => !existingIds.Contains(x.AdmManagementLevelID)); await _repository.DeleteAsync(deletedItems); }
public async Task <int> Delete(DeleteSiteTypeRequest request) { var invSiteType = _autoMapper.Map <InvSiteType>(request); var resId = invSiteType.InvSiteTypeID; await _repo.DeleteAsync(invSiteType); return(resId); }
public async Task <bool> DeleteServingPeriods(int id) { if (id == 0) { return(false); } await _repository.DeleteAsync(await _repository.FindAsync <AdmServingPeriod>(id)); return(true); }
public async Task DeleteAdmSchoolGroup(int id) { var group = await _repository.FindAsync <AdmSchoolGroup>(id); if (group != null) { if (group.IsCEPGroup) { //this looks weird to me, there is an FK in the DB which prevents group deletion if any AccRate is linked... var accCEPRates = await _repository.GetListAsync <AccCEPRates>(x => x.AdmSchoolGroupID == id); if (accCEPRates.Any()) { var accCEPRate = accCEPRates.FirstOrDefault(); await _repository.DeleteAsync(accCEPRate); } } await _repository.DeleteAsync(group); _repository.SaveChanges(); } }
public async Task <SaveGradeSitePromotionsResponse> SaveGradeSitePromotions(SaveGradeSitePromotionsRequest request) { var toSave = new List <AdmGradeSitePromotion>(); var promotions = _repository.GetQueryable <AdmGradeSitePromotion>().ToList(); await _repository.DeleteAsync <AdmGradeSitePromotion>(promotions); var modelsList = request.Promotions.Where(l => l.PromotingPosGradeID.HasValue && l.PromotingPosGradeID != 0); foreach (var model in modelsList) { DateTime today = _repository.GetSchoolNow(model.AdmSiteID); var site = promotions.FirstOrDefault(s => s.AdmSiteID == model.AdmSiteID); if (site == null) { site = new AdmGradeSitePromotion() { AdmSiteID = model.AdmSiteID, PosGradeID = model.PromotingPosGradeID ?? 0, LastUpdatedBy = request.AdmSiteId, LastUpdatedDate = today }; } if (site.PosGradeID != model.PromotingPosGradeID || site.PromoteToAdmSiteID != model.PromoteToAdmSiteID) { site.LastUpdatedBy = request.AdmSiteId; site.LastUpdatedDate = today; } site.PosGradeID = model.PromotingPosGradeID ?? 0; site.PromoteToAdmSiteID = model.PromoteToAdmSiteID; toSave.Add(site); } var createdPromotions = await _repository.CreateAsync <AdmGradeSitePromotion>(toSave); return(new SaveGradeSitePromotionsResponse { Items = _autoMapper.Map <ICollection <SavedSitePromotionModel> >(createdPromotions) }); }