public object Delete(string ID) { using (ThreadService threadService = new ThreadService()) { ResultOperation resultOperation = new ResultOperation(); foreach (Guid threadId in ID.ToStringObj().Split(',').Where(c => c.ToGuidObjNull().HasValue).Select(c => c.ToGuidObj()).ToList()) { resultOperation = threadService.Delete(threadId); if (!resultOperation.IsSuccess) { break; } } if (resultOperation.IsSuccess) { return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success)); } else { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } } }
public bool RemoveThread(string threadToRemove) { if (string.IsNullOrEmpty(threadToRemove)) { return(false); } ClaimsIdentity claimsIdentity = this.User.Identity as ClaimsIdentity; string userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; User onlineUser = this._userService.GetById(userId); // Supprimer dans threads.speakers et dans user.threads bool isRemovedThread = _userService.RemoveThread(threadToRemove, onlineUser.Id); Thread modifiedThread = _threadService.RemoveSpeaker(threadToRemove, onlineUser.Id); if (modifiedThread.Speakers.Length == 0) { _threadService.Delete(modifiedThread); } return(true); // Doit être approfondie }