public bool UpdateCoWorkerDetails(int PerId, string ComCSV) { PerformanceCoWorkerDetail coDetails = _db.PerformanceCoWorkerDetails.Where(x => x.Id == PerId && x.Archived == false).FirstOrDefault(); EditSegmentViewModel model = new EditSegmentViewModel(); JavaScriptSerializer js = new JavaScriptSerializer(); model.CoworkerSegment = js.Deserialize <List <CoworkerSegment> >(ComCSV); int totalScore = 0, totalQue = 0; foreach (var item in model.CoworkerSegment) { item.questionDataList = js.Deserialize <List <CoworkerSegmentQuetion> >(item.questionData); totalQue = totalQue + item.questionDataList.Count(); foreach (var data in item.questionDataList) { totalScore = totalScore + Convert.ToInt32(data.Score); } } int AvgCoreScore = totalScore / totalQue; coDetails.CoWorkerScoreJSC = ComCSV; coDetails.CoreScore = Convert.ToString(AvgCoreScore); coDetails.Status = "See Response"; coDetails.InviteStatus = true; coDetails.LastModifiedDate = DateTime.Now; _db.SaveChanges(); return(true); }
public int SaveCoworkerInviteLink(int invitEmpID, int PerfId, int empID) { PerformanceCoWorkerDetail model = new PerformanceCoWorkerDetail(); model.InviteEmployeeId = invitEmpID; model.EmployeeID = empID; model.PerformanceId = PerfId; model.Archived = false; model.Status = "Invited"; model.InviteStatus = false; model.CreatedDate = DateTime.Now; model.LastModifiedDate = DateTime.Now; _db.PerformanceCoWorkerDetails.Add(model); _db.SaveChanges(); return(model.Id); }