Пример #1
0
 public async Task <IHttpActionResult> DeleteCommunity(int id)
 {
     if (await _communityService.DeleteCommunity(id).ConfigureAwait(false))
     {
         return(Ok());
     }
     return(NotFound());
 }
Пример #2
0
        public async Task <bool> Delete(long?id, long?parentId)
        {
            if (CurrentUserId == 0)
            {
                await TryAuthenticateFromHttpContext();
            }
            if (id.HasValue)
            {
                if (CurrentUserId != 0)
                {
                    var status = _communityService.DeleteCommunity(id.Value, CurrentUserId);

                    return(status.Succeeded);
                    // TODO: Need to add failure functionality.
                }
            }

            return(false);
        }
        public bool DeleteOffensiveCommunity(string id)
        {
            bool status = false;

            ProfileDetails profileDetails;

            if (ValidateAuthentication(true, out profileDetails))
            {
                IProfileService profileService = DependencyResolver.Current.GetService(typeof(IProfileService)) as IProfileService;
                profileDetails = profileService.GetProfile(profileDetails.PUID);
                if (profileDetails != null)
                {
                    var details = new OffensiveEntry()
                    {
                        EntityID   = long.Parse(id, CultureInfo.InvariantCulture),
                        ReviewerID = profileDetails.ID,
                        Status     = OffensiveStatusType.Offensive
                    };

                    ICommunityService communityService = DependencyResolver.Current.GetService(typeof(ICommunityService)) as ICommunityService;
                    status = communityService.DeleteCommunity(long.Parse(id, CultureInfo.InvariantCulture), profileDetails.ID, true, details).Succeeded;

                    // Notify the Moderators and Owners about the Deleted Community.
                    INotificationService     notificationService = DependencyResolver.Current.GetService(typeof(INotificationService)) as INotificationService;
                    EntityAdminActionRequest notification        = new EntityAdminActionRequest()
                    {
                        AdminID    = profileDetails.ID,
                        EntityID   = long.Parse(id, CultureInfo.InvariantCulture),
                        EntityType = EntityType.Community,
                        EntityLink = string.Format(CultureInfo.InvariantCulture, "{0}/Community/Index/{1}", HttpContext.Current.Request.UrlReferrer.GetApplicationPath(), id),
                        Action     = AdminActions.Delete
                    };

                    notificationService.NotifyEntityDeleteRequest(notification);
                }
                else
                {
                    throw new WebFaultException <string>(Resources.UserNotRegisteredMessage, HttpStatusCode.Unauthorized);
                }
            }

            return(status);
        }