Ejemplo n.º 1
0
        public ActionResult Delete(UserAvatarDelete value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var avatar = this.UserAvatarService.GetById(value.Id);

            if (avatar == null)
            {
                return base.HttpNotFound();
            }

            var privilege = new UserAvatarPrivilege();

            if (!privilege.CanDelete(avatar))
            {
                return NotAuthorized();
            }

            var user = this.UserService.GetById(Identity.Id);
            var matched = this.UserAvatarService.RemoveFromUserOnMatch(user, avatar);

            if (matched)
            {
                this.UserService.Update(user);
            }

            this.UserAvatarService.Delete(avatar);

            return base.RedirectToRoute(UsersRoutes.AvatarIndex);
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            var avatar = this.UserAvatarService.GetById(id);

            if (avatar == null)
            {
                return base.HttpNotFound();
            }

            var privilege = new UserAvatarPrivilege();

            return privilege.CanDelete(avatar) ? base.View(Views.Delete, new UserAvatarDelete(avatar)) : NotAuthorized();
        }