Пример #1
0
        public JsonResult Delete(int id)
        {
            CommunityTopic item = this.communityService.GetTopic(id);

            if (item == null)
            {
                return(Json(new { status = HttpStatusCode.NoContent }));
            }
            var             adminRole = memberService.GetUserRoles().SingleOrDefault(r => r.Name == MemberRoles.Admin.ToString());
            ApplicationUser currUser  = memberService.GetUser(User.Identity.Name);

            if (item.AuthorUserID == currUser.Id || currUser.Roles.Any(r => r.RoleId == adminRole.Id))
            {
                communityService.DeleteTopic(item);
                communityService.SaveTopic();
                TempData["ReloadData"] = true;
                return(Json(new { status = HttpStatusCode.OK }));
            }
            return(Json(""));
        }