コード例 #1
0
ファイル: AvatarController.cs プロジェクト: Mike343/Netcoders
        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);
        }
コード例 #2
0
ファイル: AvatarController.cs プロジェクト: Mike343/Netcoders
        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();
        }