public async Task <bool> PostFeedbackAsync(FeedbackReportSubmission feedback) { using (var client = new HttpClient()) { SetupHttpClient(client); HttpResponseMessage response = await client.PostAsJsonAsync("api/FeedbackReports", feedback); if (!response.IsSuccessStatusCode) { return(false); } else { return(true); } } }
private FeedbackReport ConvertReportSubmissionToFeedbackReport(FeedbackReportSubmission reportSubmission) { var feedback = new FeedbackReport { Session = Session.Session, RatePresentation = reportSubmission.RatePresentation, RateContent = reportSubmission.RateContent, RateDelivery = reportSubmission.RateDelivery, RateSlides = reportSubmission.RateSlides, RateDemos = reportSubmission.RateDemos, LikeComments = reportSubmission.LikeComments, DislikeComments = reportSubmission.DislikeComments, GeneralComments = reportSubmission.GeneralComments }; return(feedback); }
public async Task <IHttpActionResult> PostFeedbackReport(FeedbackReportSubmission feedbackReport) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var report = await db.FeedbackReports.FirstOrDefaultAsync(fbr => fbr.Session.Id == feedbackReport.SessionId && fbr.Attendee.ClientId == feedbackReport.ClientId); var attendee = await db.Attendees.FirstOrDefaultAsync(a => a.ClientId == feedbackReport.ClientId) ?? new Attendee { ClientId = feedbackReport.ClientId }; attendee.Name = string.IsNullOrWhiteSpace(feedbackReport.UserName) ? attendee.Name : feedbackReport.UserName; var session = await db.Sessions.FirstOrDefaultAsync(s => s.Id == feedbackReport.SessionId); if (report == null) { report = new FeedbackReport(); db.FeedbackReports.Add(report); } report.Attendee = attendee; report.RatePresentation = feedbackReport.RatePresentation; report.RateContent = feedbackReport.RateContent; report.RateDelivery = feedbackReport.RateDelivery; report.RateSlides = feedbackReport.RateSlides; report.RateDemos = feedbackReport.RateDemos; report.LikeComments = feedbackReport.LikeComments; report.DislikeComments = feedbackReport.DislikeComments; report.GeneralComments = feedbackReport.GeneralComments; report.Session = session; await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = report.Id }, feedbackReport)); }