public int Save(MgrPerReviewPerformanceModel model) { var managerPerReviewPerformance = Mapper.DynamicMap <tblMgrPerReviewPerformance>(model); _mgrPerReviewRepository.Add(managerPerReviewPerformance); return(_mgrPerReviewRepository.SaveChanges()); }
// POST api/<controller> public int Post([FromBody] MgrPerReviewPerformanceModel model) { if (model != null && model.MgrReviewID == 0) { model.CreatedBy = base.UserName; model.CreatedDate = DateTime.Now; model.Status = true; model.EmpID = int.Parse(base.UserIdentity); model.RepMgrID = int.Parse(base.UserIdentity) != model.EmpID ? model.EmpID : null; // empid may be login or selected empid //model.RepMgrID = base.ReportingManagerId; foreach (var segments in model.tblMgrPerReviewSegments) { foreach (var question in segments.tblMgrPerReviewRatings) { question.CreatedDate = DateTime.Now; question.CreatedBy = base.UserName; } } return(_managerPerformanceService.Save(model)); } else { model.UpdatedBy = base.UserName; model.UpdatedDate = DateTime.Now; model.Status = true; model.EmpID = int.Parse(base.UserIdentity); model.RepMgrID = int.Parse(base.UserIdentity) != model.EmpID ? model.EmpID : null; foreach (var segments in model.tblMgrPerReviewSegments) { foreach (var question in segments.tblMgrPerReviewRatings) { question.UpdatedDate = DateTime.Now; question.UpdatedBy = base.UserName; } } return(_managerPerformanceService.Update(model)); } }
public int Update(MgrPerReviewPerformanceModel model) { tblMgrPerReviewPerformance mgrReview = _mgrPerReviewRepository .GetEmpPerReviewPerformancesById(model.MgrReviewID); for (int i = 0; i < model.tblMgrPerReviewSegments.Count; i++) { for (int j = 0; j < model.tblMgrPerReviewSegments[i].tblMgrPerReviewRatings.Count; j++) { mgrReview.tblMgrPerReviewSegments[i].tblMgrPerReviewRatings[j].ScoreID = model.tblMgrPerReviewSegments[i].tblMgrPerReviewRatings[j].ScoreID; mgrReview.tblMgrPerReviewSegments[i].tblMgrPerReviewRatings[j].Answer = model.tblMgrPerReviewSegments[i].tblMgrPerReviewRatings[j].Answer; } } _mgrPerReviewRepository.Update(mgrReview); return(_mgrPerReviewRepository.SaveChanges()); }