Ejemplo n.º 1
0
        // GET: Ratings/Details/5
        public async Task <ActionResult> Details(int id, string ratedUserName)
        {
            var rating = await RatingFacade.GetRatingsAsync(id);

            var creator = await UserFacade.GetUserAsync(rating.CreatorId);

            return(View("RatingDetailView", InitializeRatingViewModel(rating, creator.UserName, ratedUserName, rating.RatedUserId, rating.RatedUserRole.ToString())));
        }
Ejemplo n.º 2
0
        // GET: Ratings/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            var rating = await RatingFacade.GetRatingsAsync(id);

            RemoveUserRating(rating);

            await RatingFacade.DeleteRatingAsync(id);

            string userRoleListRoute = "~/Views/" + rating.RatedUserRole + "s/" + rating.RatedUserRole + "DetailView.cshtml";

            return(RedirectToAction("Details", rating.RatedUserRole + "s", new { id = rating.RatedUserId }));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Delete(int id, FormCollection collection)
        {
            try
            {
                var rating = await RatingFacade.GetRatingsAsync(id);

                return(RedirectToAction("Index", "", null));
            }
            catch
            {
                return(View("~/Views/Home/GeneralExceptionView.cshtml"));
            }
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Edit(int id, FormCollection collection)
        {
            try
            {
                var newRating = await RatingFacade.GetRatingsAsync(id);

                foreach (string key in collection.Keys)
                {
                    switch (key)
                    {
                    case "Score":
                        int newScore;
                        if (Int32.TryParse(collection[key], out newScore))
                        {
                            newRating.Score = newScore;
                        }
                        break;

                    case "Comment":
                        newRating.Comment = collection[key];
                        break;
                    }
                }

                bool success = await RatingFacade.EditRatingAsync(newRating);

                if (!success)
                {
                    // THROW ERROR
                }

                return(RedirectToAction("Details", new { id = id }));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 5
0
        // GET: Ratings/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            var rating = await RatingFacade.GetRatingsAsync(id);

            return(View("RatingEditView", rating));
        }