public AddNewsResult Save([FromBody] SaveNewsRequest addrequest) { try { if (addrequest == null || addrequest.News == null) { throw new ArgumentNullException(nameof(SaveNewsRequest)); } CategoryDTO newsCategory = CategoryManager.GetByID(addrequest.News.CategoryId); CategoryManager.CheckIsUserAuthonticatedToEditDelete(User.GetUserId(), newsCategory); // Check if the current user is authorized to make this operation if (!addrequest.News.Id.HasValue) { addrequest.News.CreateUser = User.GetUserId(); } else { NewsManager.CheckIsUserAuthonticatedToEditDelete(User.GetUserId(), addrequest.News); } if (addrequest.News.IconName.CheckIsNull()) { addrequest.News.IconName = Guid.NewGuid().ToString(); } NewsManager.Save(addrequest.News); if (addrequest.News.Icon != null && addrequest.News.Icon.Length > 0) { ImageExtensions.SaveImage(GetNewsImagePath(addrequest.News.IconName), addrequest.News.Icon); } return(new AddNewsResult() { }); } catch (Exception ex) { return(new AddNewsResult(ex)); } }