} //End public TatibCRUD() public void Create(TatibdetailVM poViewModel) { try { using (var db = new DBMAINContext()) { Tatib oModel = new Tatib(); //Map Form Data oModel.InjectFrom(poViewModel); //Set Field Header oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE); //Process CRUD db.Tatibs.Add(oModel); db.SaveChanges(); this.ID = oModel.ID; } //End using } //End try catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Create: " + e.Message; } //End catch } //End public void Create
} //End public void Create public void Update(TatibdetailVM poViewModel) { try { using (var db = new DBMAINContext()) { Tatib oModel = db.Tatibs.AsNoTracking().SingleOrDefault(fld => fld.ID == poViewModel.ID); //Map Form Data oModel.InjectFrom(poViewModel); //Set Field Header oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE); //Process CRUD db.Entry(oModel).State = EntityState.Modified; db.SaveChanges(); this.ID = oModel.ID; } //End using } //End try catch (Exception e) { isERR = true; this.ERRMSG = "CRUD - Update" + e.Message; } //End catch } //End public void Update
//Constructor public Tatib_Validation(TatibdetailVM poViewModel) { oViewModel = poViewModel; } //End public Tatib_Validation()