public ResponseData AddByEntity(CapabilityDetailViewModel data) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { tb_Capability_Detail model = new tb_Capability_Detail(); model.CapDID = data.CapDID; model.CapDName = data.CapDName; model.CapDDesc = data.CapDDesc; model.CapID = data.CapID; model.Score1 = data.Score1; model.Score2 = data.Score2; model.CreateBy = UtilityService.User.UserID; model.CreateDate = DateTime.Now; model.ModifyBy = UtilityService.User.UserID; model.ModifyDate = DateTime.Now; db.tb_Capability_Detail.Add(model); db.SaveChanges(); } catch (Exception) { } return(result); } }
public JsonResult SaveCapabilityDetail(CapabilityDetailViewModel model) { ResponseData result = new Models.ResponseData(); if (model.CapID != 0) { result = new CapabilityDetailRepository().UpdateByEntity(model); } else { result = new CapabilityDetailRepository().AddByEntity(model); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ResponseData UpdateByEntity(CapabilityDetailViewModel newdata) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { var data = db.tb_Capability_Detail.Single(x => x.CapID == newdata.CapID); data.CapDID = newdata.CapDID; data.CapDName = newdata.CapDName; data.CapDDesc = newdata.CapDDesc; data.CapID = newdata.CapID; data.Score1 = newdata.Score1; data.Score2 = newdata.Score2; data.ModifyBy = UtilityService.User.UserID; data.ModifyDate = DateTime.Now; db.SaveChanges(); } catch (Exception) { } return(result); } }