public IHttpActionResult Put(LeaderRatingEdit rating)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = GetLeaderRatingService();

            if (!service.EditLeaderRating(rating))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Exemplo n.º 2
0
        public bool EditLeaderRating(LeaderRatingEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.LeaderRatings.Single(r => r.LeaderRatingID == model.LeaderRatingID);

                entity.SpeakingAbilityRating = model.SpeakingAbilityRating;
                entity.EngagingRating        = model.EngagingRating;
                entity.AuthenticRating       = model.AuthenticRating;
                entity.RapportRating         = model.RapportRating;

                if (ctx.SaveChanges() == 1)
                {
                    CalculateSpeakingAbilityRating(model.LeaderID);
                    CalculateEngagingRating(model.LeaderID);
                    CalculateAuthenticRating(model.LeaderID);
                    CalculateRapportRating(model.LeaderID);
                    return(true);
                }
                return(false);
            }
        }