} //End public ProjectCRUD() public void Create(Project_DetailVM poViewModel) { string vsMsgErr = ""; try { using (var db = new DBMAINContext()) { Project oModel = new Project(); //Map Form Data Mapper.CreateMap <Project_DetailVM, Project>(); oModel = Mapper.Map <Project_DetailVM, Project>(poViewModel); //Set Field Header oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE); //Set DTA_STS oModel.DTA_STS = valFLAG.FLAG_DTA_STS_CREATE; //Process CRUD db.Projects.Add(oModel); db.SaveChanges(); } //End using } //End try catch (Exception e) { vsMsgErr = e.Message; } //End catch } //End public void Create
} //End public void Create public void Update(Project_DetailVM poViewModel) { string vsMsgErr = ""; try { using (var db = new DBMAINContext()) { Project oModel = db.Projects.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID); //Map Form Data Mapper.CreateMap <Project_DetailVM, Project>(); oModel = Mapper.Map <Project_DetailVM, Project>(poViewModel); //Set Field Header oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE); //Set DTA_STS oModel.DTA_STS = valFLAG.FLAG_DTA_STS_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
//Constructor public Project_Validation(Project_DetailVM poViewModel) { oViewModel = poViewModel; } //End public Project_Validation()