Пример #1
0
 public void ModifyRegion(RegionDE mod)
 {
     _regionRepo.Update(mod);
     _regionRepo.CommitAllChanges();
 }
Пример #2
0
 public RegionViewModel()
 {
     //base.FieldId = "regionCode";
     Region = new RegionDE();
     Regions = new List<RegionDE>();
 }
Пример #3
0
 public decimal AddRegion(RegionDE mod)
 {
     _regionRepo.Insert(mod);
     _userRepo.CommitAllChanges();
     return mod.ID;
 }
Пример #4
0
        public RegionViewModel ModifyRegion(RegionDE mod)
        {
            RegionViewModel model = new RegionViewModel();

            try
            {
                DBOperations op = mod.IsActive ? DBOperations.Update : DBOperations.Delete;
                mod.SiteCode = AppConstants.SITE_CODE;
                _bdmSvc.ModifyRegion(mod);

                model.Region = new RegionDE();
                model.FieldId = "regionCode";
                model.Regions = _bdmSvc.GetAllRegions(AppConstants.SITE_CODE); //.GetAllRegions().Map(model.Regions);
                model.Message = op == DBOperations.Update ? string.Format(AppConstants.CRUD_UPDATE, "Region") : string.Format(AppConstants.CRUD_DELETE, "Region");
            }
            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;
        }