} //End public void Update public void Delete(string id) { string vsMsgErr = ""; try { using (var db = new DBMAINContext()) { Subtype oModel = db.Subtypes.Find(id); db.Subtypes.Remove(oModel); db.SaveChanges(); } //End using } //End try catch (Exception e) { vsMsgErr = e.Message; } //End catch } //End public void Delete
} //End public void Create public void Update(Subtype_DetailVM poViewModel) { string vsMsgErr = ""; try { using (var db = new DBMAINContext()) { Subtype oModel = db.Subtypes.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID); //Map Form Data Mapper.CreateMap <Subtype_DetailVM, Subtype>(); oModel = Mapper.Map <Subtype_DetailVM, Subtype>(poViewModel); //Set Field Header oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE); //Set DTA_STS oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_UPDATE; //Process CRUD db.Entry(oModel).State = EntityState.Modified; db.SaveChanges(); } //End using } //End try catch (Exception e) { vsMsgErr = e.Message; } //End catch } //End public void Update
} //End public SubtypeCRUD() public void Create(Subtype_DetailVM poViewModel) { string vsMsgErr = ""; try { using (var db = new DBMAINContext()) { Subtype oModel = new Subtype(); //Map Form Data Mapper.CreateMap <Subtype_DetailVM, Subtype>(); oModel = Mapper.Map <Subtype_DetailVM, Subtype>(poViewModel); //Set Field Header oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE); //Set DTA_STS oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_CREATE; //Process CRUD db.Subtypes.Add(oModel); db.SaveChanges(); } //End using } //End try catch (Exception e) { vsMsgErr = e.Message; } //End catch } //End public void Create