// Edit
        public ActionResult Edit(int id)
        {
            var service = CreateRatingService();
            var detail  = service.GetRatingDetail(id);
            var model   =
                new RatingUpdate
            {
                Rating = detail.Rating
            };

            return(View(model));
        }
Beispiel #2
0
        public bool UpdateRating(RatingUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Ratings.Single(e => e.RatingId == model.RatingId);

                entity.EnjoymentScore   = model.EnjoymentScore;
                entity.EngagementScore  = model.EngagementScore;
                entity.AuthorStyleScore = model.AuthorStyleScore;
                entity.Description      = model.Description;

                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #3
0
        // Update
        public bool UpdateRating(RatingUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .SafetyRatings
                    .Single(e => e.Id == model.Id);

                entity.Rating = model.Rating;

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Put(RatingUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var _service = CreateRatingService();

            if (!_service.UpdateRating(model))
            {
                return(InternalServerError());
            }

            return(Ok("Rating updated."));
        }
Beispiel #5
0
        public ActionResult Update(int id)
        {
            var _service = CreateRatingService();
            var detail   = _service.GetRatingById(id);
            var model    =
                new RatingUpdate
            {
                RatingId         = detail.RatingId,
                EnjoymentScore   = detail.EnjoymentScore,
                SongLengthScore  = detail.SongLengthScore,
                ArtistStyleScore = detail.ArtistStyleScore,
                Description      = detail.Description
            };

            return(View(model));
        }
Beispiel #6
0
        public ActionResult Update(int id, RatingUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.RatingId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var _service = CreateRatingService();

            if (_service.UpdateRating(model))
            {
                TempData["SaveResult"] = "Your Rating was updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your Rating could not be updated.");
            return(View(model));
        }
        public ActionResult Edit(int id, RatingUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.Id != id)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }

            var service = CreateRatingService();

            if (service.UpdateRating(model))
            {
                TempData["SaveResult"] = "Safety Rating was updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Safety Rating could not be updated");
            return(View(model));
        }