private bool isparameterused(PERFORMANCEPARAMETER p) { if (rlist == null) { return(true); } REVIEW rev = rlist.Find(r => r.PerameterId == p.ParameterId); if (rev == null) { return(true); } else { return(false); } }
protected void Save_Click(object sender, EventArgs e) { //code to delete the previously set reviews deletereviews(g.GenerateReviewId); bool error = false; foreach (TableRow tr in ParametersTable.Rows) { if (tr.Cells.Count == 3 && tr != ParametersTable.Rows[0]) { Label paramname = (Label)tr.Cells[0].FindControl(ParametersTable.Rows.GetRowIndex(tr).ToString()); PERFORMANCEPARAMETER p = parameterList.FirstOrDefault(pr => pr.ParameterName == paramname.Text); REVIEW r = new REVIEW(); r.GenerateReviewId = g.GenerateReviewId; r.EmployeeId = g.EmployeeId; r.PerameterId = p.ParameterId; TextBox comment = (TextBox)tr.Cells[2].FindControl(p.ParameterId + p.ParameterName); r.Comment = comment.Text; for (int i = p.MinRating; i <= p.MaxRating; i++) { RadioButton rb = (RadioButton)tr.Cells[1].FindControl(p.ParameterName + i); if (rb.Checked) { r.Rating = Convert.ToInt32(rb.Text); break; } } //update reviews in db // Response.Write(r.GenerateReviewId + " " +r.PerameterId+" "+ r.Rating + " " + r.Comment + "\n" ); var client = new HttpClient(); client.BaseAddress = new Uri(Global.URIstring); var postTask = client.PostAsJsonAsync <REVIEW>("reviews", r); postTask.Wait(); var result = postTask.Result; if (!result.IsSuccessStatusCode) { // occurs if some error in writing to db Response.Write("Some error occured"); //TODO take appt. action for the error error = true; break; } } } if (!error) { //update generatedreview status g.Status = "Assessed"; var client = new HttpClient(); client.BaseAddress = new Uri(Global.URIstring); var putTask = client.PutAsJsonAsync <GENERATEREVIEW>("generatedreviews/" + g.GenerateReviewId, g); putTask.Wait(); var result = putTask.Result; if (result.IsSuccessStatusCode) { Response.Write("Review assessed successfully."); Response.Redirect("CompletedReviews.aspx"); } } }