//[ResponseType(typeof(String))] public HttpResponseMessage add([FromBody] List <SatisfactionResults> responseList) { if (responseList.Count != 0 && (authRepo.getTeamLeadRights(responseList[0].AccountId) || authRepo.getAccountRights(responseList[0].AccountId))) { List <Object[]> pastResultList = repo.getReviweData(responseList[0].AccountId, responseList[0].Year, responseList[0].Quarter, responseList[0].MemberId); if (pastResultList.Count == 0) { //String[] outputArray= text.Split('~'); int singleRating = 0; List <Questions> displayingQuestions = questionrepo.getDisplayingQuestions(1); for (int i = 0; i < responseList.Count; i++) { SatisfactionResults satResults = new SatisfactionResults(); //Debug.WriteLine("gdfg " + outputArray[i]); //String[] resultedArray=outputArray[i].Split('|'); satResults.MemberId = responseList[i].MemberId; satResults.AccountId = responseList[i].AccountId; satResults.ProjectId = responseList[i].ProjectId; satResults.Year = responseList[i].Year; satResults.Quarter = responseList[i].Quarter; satResults.QuestionId = responseList[i].QuestionId; if (responseList[i].Answer == "undefined" || responseList[i].Answer == null || responseList[i].Answer == "null") { satResults.Answer = "0"; satResults.Comment = responseList[i].Comment; } else { satResults.Answer = responseList[i].Answer; satResults.Comment = responseList[i].Comment; } repo.add(satResults); foreach (Questions qu in displayingQuestions) { if (qu.Id == satResults.QuestionId) { singleRating = singleRating + Convert.ToInt32(satResults.Answer); } } } double employeeSummary = (double)((double)singleRating / (displayingQuestions.Count)); Debug.WriteLine("SingleSummary " + employeeSummary); TeamSatisfactionEmployeeSummary teamSatisfactionEmpSummary = new TeamSatisfactionEmployeeSummary(); //String[] newResultedArray = outputArray[1].Split('|'); SatisfactionResults tempResult = responseList[0]; teamSatisfactionEmpSummary.empId = tempResult.MemberId; teamSatisfactionEmpSummary.AccountId = tempResult.AccountId; teamSatisfactionEmpSummary.Year = tempResult.Year; teamSatisfactionEmpSummary.Quarter = tempResult.Quarter; teamSatisfactionEmpSummary.Rating = employeeSummary; teamSatEmployeeSummaryRepo.add(teamSatisfactionEmpSummary); double summaryAverage = teamSatEmployeeSummaryRepo.getSelectedAccountSummaryTotal(tempResult.AccountId, tempResult.Year, tempResult.Quarter); int affectedCount = summaryRepo.updateSelectedSummary(tempResult.AccountId, tempResult.Year, tempResult.Quarter, summaryAverage); //SatisfactionResults sat = new SatisfactionResults(); //sat.MemberId = empId; //sat.AccountId = accId; //sat.Year = year; //sat.ProjectId = teamId; //sat.Quarter = quarter; //sat.QuestionId = qId; //if (rate != -1) //{ // sat.Answer = rate.ToString(); // sat.Comment = comment; //} //else { // sat.Comment = comment; // sat.Answer = "0"; //} //int returnRowData=repo.add(sat); //count++; //Debug.WriteLine(count+" fdsf " + empId + " " + accId + " " + year + " " + quarter + " " + qId + " " + rate + " " + comment); //List<Questions> displayingQuestions=questionrepo.getDisplayingQuestions(1); //foreach (Questions qu in displayingQuestions) { // if (qu.Id == sat.QuestionId) { // singleRating = singleRating + Convert.ToInt32(sat.Answer); // } //} //if (count == questionLength) { // Debug.WriteLine("ResultEntered "+singleRating); // double finalEmployeeRating = singleRating / questionLength; // TeamSatisfactionEmployeeSummary teamSatisfactionEmpSummary = new TeamSatisfactionEmployeeSummary(); // teamSatisfactionEmpSummary.empId = empId; // teamSatisfactionEmpSummary.AccountId = accId; // teamSatisfactionEmpSummary.Year = year; // teamSatisfactionEmpSummary.Quarter = quarter; // teamSatisfactionEmpSummary.Rating = finalEmployeeRating; // teamSatEmployeeSummaryRepo.add(teamSatisfactionEmpSummary); //} return(Request.CreateResponse(HttpStatusCode.OK, affectedCount));; } else { return(Request.CreateResponse(HttpStatusCode.Forbidden, "You have already filled survey for selected quarter. Please try another quarter")); } } else { return(Request.CreateResponse(HttpStatusCode.Forbidden, "Trying perform an invalid action....Access denied")); } //return 1; }
//[ResponseType(typeof(String))] public int add([FromBody] string text) { String[] outputArray = text.Split('~'); int singleRating = 0; List <Questions> displayingQuestions = questionrepo.getDisplayingQuestions(1); for (int i = 1; i < outputArray.Length; i++) { SatisfactionResults satResults = new SatisfactionResults(); Debug.WriteLine("gdfg " + outputArray[i]); String[] resultedArray = outputArray[i].Split('|'); satResults.MemberId = Convert.ToInt32(resultedArray[0]); satResults.AccountId = Convert.ToInt32(resultedArray[1]); satResults.ProjectId = Convert.ToInt32(resultedArray[2]); satResults.Year = Convert.ToInt32(resultedArray[3]); satResults.Quarter = Convert.ToInt32(resultedArray[4]); satResults.QuestionId = Convert.ToInt32(resultedArray[5]); if (resultedArray[6].Equals("undefined")) { satResults.Answer = "0"; satResults.Comment = resultedArray[7]; } else { satResults.Answer = resultedArray[6]; satResults.Comment = resultedArray[7]; } repo.add(satResults); foreach (Questions qu in displayingQuestions) { if (qu.Id == satResults.QuestionId) { singleRating = singleRating + Convert.ToInt32(satResults.Answer); } } } double employeeSummary = (double)((double)singleRating / (displayingQuestions.Count)); Debug.WriteLine("SingleSummary " + employeeSummary); TeamSatisfactionEmployeeSummary teamSatisfactionEmpSummary = new TeamSatisfactionEmployeeSummary(); String[] newResultedArray = outputArray[1].Split('|'); teamSatisfactionEmpSummary.empId = Convert.ToInt32(newResultedArray[0]); teamSatisfactionEmpSummary.AccountId = Convert.ToInt32(newResultedArray[1]); teamSatisfactionEmpSummary.Year = Convert.ToInt32(newResultedArray[3]); teamSatisfactionEmpSummary.Quarter = Convert.ToInt32(newResultedArray[4]); teamSatisfactionEmpSummary.Rating = employeeSummary; teamSatEmployeeSummaryRepo.add(teamSatisfactionEmpSummary); double summaryAverage = teamSatEmployeeSummaryRepo.getSelectedAccountSummaryTotal(Convert.ToInt32(newResultedArray[1]), Convert.ToInt32(newResultedArray[3]), Convert.ToInt32(newResultedArray[4])); int affectedCount = summaryRepo.updateSelectedSummary(Convert.ToInt32(newResultedArray[1]), Convert.ToInt32(newResultedArray[3]), Convert.ToInt32(newResultedArray[4]), summaryAverage); //SatisfactionResults sat = new SatisfactionResults(); //sat.MemberId = empId; //sat.AccountId = accId; //sat.Year = year; //sat.ProjectId = teamId; //sat.Quarter = quarter; //sat.QuestionId = qId; //if (rate != -1) //{ // sat.Answer = rate.ToString(); // sat.Comment = comment; //} //else { // sat.Comment = comment; // sat.Answer = "0"; //} //int returnRowData=repo.add(sat); //count++; //Debug.WriteLine(count+" fdsf " + empId + " " + accId + " " + year + " " + quarter + " " + qId + " " + rate + " " + comment); //List<Questions> displayingQuestions=questionrepo.getDisplayingQuestions(1); //foreach (Questions qu in displayingQuestions) { // if (qu.Id == sat.QuestionId) { // singleRating = singleRating + Convert.ToInt32(sat.Answer); // } //} //if (count == questionLength) { // Debug.WriteLine("ResultEntered "+singleRating); // double finalEmployeeRating = singleRating / questionLength; // TeamSatisfactionEmployeeSummary teamSatisfactionEmpSummary = new TeamSatisfactionEmployeeSummary(); // teamSatisfactionEmpSummary.empId = empId; // teamSatisfactionEmpSummary.AccountId = accId; // teamSatisfactionEmpSummary.Year = year; // teamSatisfactionEmpSummary.Quarter = quarter; // teamSatisfactionEmpSummary.Rating = finalEmployeeRating; // teamSatEmployeeSummaryRepo.add(teamSatisfactionEmpSummary); //} return(affectedCount); }