Ejemplo n.º 1
0
        public ActionResult Update(EditViewModel m)
        {
            var media = mediaSvc.GetMediaByID(m.ID);

            if (ModelState.IsValid)
            {
                media.Title = m.Title;
                media.Description = m.Description;
                mediaSvc.UpdateMedia(media);

                if (string.IsNullOrWhiteSpace(m.ReturnUrl)) { return RedirectToAction("UsersSubmittedMedia", new { id = CfIdentity.UserID }); }
                else { return Redirect(m.ReturnUrl); }
            }
            else
            {
                return View("Edit",m);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(Guid id)
        {
            var media = mediaSvc.GetMediaByID(id);
            ViewBag.Media = media;

            if (media.AddedByUserID != CfIdentity.UserID)
            {
                throw new AccessViolationException("You cannot edit media that does not belong to you");
            }

            var returnUrl = string.Empty;
            if (HttpContext.Request.UrlReferrer != null) { returnUrl = HttpContext.Request.UrlReferrer.ToString(); }

            var model = new EditViewModel() { ID = media.ID, ReturnUrl = returnUrl, Description = media.Description, Title = media.Title };

            return View(model);
        }