public bool CreateRating(LeaderRatingCreate model) { var rating = new LeaderRating { LeaderID = model.LeaderID, SpeakingAbilityRating = model.SpeakingAbilityRating, EngagingRating = model.EngagingRating, AuthenticRating = model.AuthenticRating, RapportRating = model.RapportRating, UserID = model.UserID }; using (var ctx = new ApplicationDbContext()) { ctx.LeaderRatings.Add(rating); if (ctx.SaveChanges() == 1) { CalculateSpeakingAbilityRating(rating.LeaderID); CalculateEngagingRating(rating.LeaderID); CalculateAuthenticRating(rating.LeaderID); CalculateRapportRating(rating.LeaderID); return(true); } return(false); } }
public IHttpActionResult Post(LeaderRatingCreate rating) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = GetLeaderRatingService(); if (!service.CreateRating(rating)) { return(InternalServerError()); } return(Ok()); }