public IActionResult Put([FromBody] HashtagUpdateDTO hashtagUpdateDTO) { try { _hashtagService.UpdateValidation(hashtagUpdateDTO); _hashtagService.Update(hashtagUpdateDTO); return(Ok()); } catch (AuthenticationException) { return(Forbid()); } catch (ServiceException ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(BadRequest(ex.StackTrace)); } }
public ActionResult HomePage(Tweet tweet, Hashtag hashtag, HttpPostedFileBase[] PhotoVideo, Photo photo, Video video)//Tweet ve Hashtag Ekleme { AppUser gelen = (AppUser)Session["oturum"]; if (Session["oturum"] != null) { gelen = (AppUser)Session["oturum"]; tweet.AppUserID = gelen.ID; } if (ModelState.IsValid) { tweet.Like = 0; tweet.Dislike = 0; tweet.Retweet = 0; #region Add Hashtag if (tweet.TweetText != null) { if (tweet.TweetText.Contains('#')) { string[] text = tweet.TweetText.Split(' '); foreach (var item in text) { if (hs.Any(x => x.HashTag.Contains(item))) { var hashtagItem = hs.GetByDefault(x => x.HashTag == item); hashtagItem.Quantity += 1; hashtagItem.Tweets.Add(tweet); hs.Update(hashtagItem); } else { if (item.Contains('#')) { hashtag.HashTag = item; hashtag.Quantity = 1; tweet.Hashtags.Add(hashtag); ts.Add(tweet); } } } } else { ts.Add(tweet); } } else { ViewBag.Message = "Tweet Giriniz."; return(View()); } #endregion #region Add Photo and Video bool isUploadedVideo; bool isUploadedPhoto; foreach (var itemPhoto in PhotoVideo) { if (itemPhoto != null) { if (itemPhoto.ContentType.Contains("image")) { string photoFileResult = FxFunction.Upload(PhotoVideo, FolderPath.TweetPhoto, out isUploadedPhoto); if (isUploadedPhoto) { photo.TweetID = tweet.ID; photo.Description = tweet.TweetText; photo.ImagePath = photoFileResult; ps.Add(photo); } } else if (itemPhoto.ContentType.Contains("video")) { string videoFileResult = FxFunction.Upload(PhotoVideo, FolderPath.TweetMovie, out isUploadedVideo); if (isUploadedVideo) { video.ID = Guid.NewGuid(); video.Description = tweet.TweetText; video.VideoPath = videoFileResult; vs.Add(video); tweet.TweetVideoID = video.ID; ts.Update(tweet); } } } } return(RedirectToAction("HomePage")); #endregion } else { ViewBag.Message = "Ekleme sırasında hata oluştu."; } ViewBag.AppUserID = new SelectList(aus.GetActive(), "ID", "Name", tweet.AppUserID); return(View()); }