public AreaViewModel() { Area = new AreaDE(); Areas = new List<AreaVw>(); Cities = new List<CityDE>(); Regions = new List<RegionDE>(); ViewName = "Distribution Point"; }
public decimal AddArea(AreaDE mod) { _areaRepo.Insert(mod); _areaRepo.CommitAllChanges(); return mod.ID; }
public void ModifyArea(AreaDE mod) { _areaRepo.Update(mod); _areaRepo.CommitAllChanges(); }
public AreaViewModel ModifyArea(AreaDE mod) { AreaViewModel model = new AreaViewModel(); try { DBOperations op = mod.IsActive ? DBOperations.Update : DBOperations.Delete; mod.SiteCode = AppConstants.SITE_CODE; model.Area = mod; model.IsValid = model.Validate(); if (model.IsValid) { _bdmSvc.ModifyArea(mod); model.FieldId = "areaCode"; model.Area = new AreaDE(); model.Regions = _bdmSvc.GetAllRegions(AppConstants.SITE_CODE); model.Areas = _bdmSvc.GetViewOfAllAreas(AppConstants.SITE_CODE); model.Message = op == DBOperations.Update ? string.Format(AppConstants.CRUD_UPDATE, model.ViewName) : string.Format(AppConstants.CRUD_DELETE, "Area"); } } catch (Exception ex) { model.IsValid = false; model.Message = ex.Message; if (ex.Message.Contains("Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions.")) model.Message = "Unable to modify Region Code"; } return model; }