예제 #1
0
        public ActionResult Writer(TweetWithImgs TweetWi)
        {
            SecurityService.Session = System.Web.HttpContext.Current.Session;
            SecurityService.Users   = new EfModelRepository {
            };
            if (!SecurityService.IsAuthenticated)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                if (ModelState.IsValid)
                // Нужно отправить данные нового гостя по электронной почте
                // организатору вечеринки.
                {
                    SecurityService.Session = System.Web.HttpContext.Current.Session;

                    TweetWi.Tweet.author = Session["UserId"].ToString();
                    PostsRepository.CreatePost(TweetWi.Tweet);

                    if (TweetWi.Imgs.Count() > 0)
                    {
                        foreach (var img in TweetWi.Imgs)
                        {
                            TweetImg Pic = new TweetImg();
                            Pic.tweeID = TweetWi.Tweet.id;
                            Stream fileStream = img.InputStream;
                            var    mStreamer  = new MemoryStream();
                            mStreamer.SetLength(fileStream.Length);
                            fileStream.Read(mStreamer.GetBuffer(), 0, (int)fileStream.Length);
                            mStreamer.Seek(0, SeekOrigin.Begin);
                            byte[] fileBytes = mStreamer.GetBuffer();
                            //SecurityService.Session = System.Web.HttpContext.Current.Session;
                            // Img ImPic = new Img();
                            // ImPic.author = Session["UserId"].ToString();
                            Pic.image = fileBytes;
                            //ImgsRepository.AddImg(ImPic);
                            // Pic.image =
                            TweetsImgsRepository.AddImg(Pic);
                        }
                    }
                    return(RedirectToAction("Inbox"));
                }
                else
                {
                    // Обнаружена ошибка проверки достоверности
                    return(View());
                }
            }
        }
예제 #2
0
 public ActionResult Writer()
 {
     SecurityService.Session = System.Web.HttpContext.Current.Session;
     SecurityService.Users   = new EfModelRepository {
     };
     if (!SecurityService.IsAuthenticated)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         SecurityService.Session = System.Web.HttpContext.Current.Session;
         TweetWithImgs tweet = new TweetWithImgs();
         tweet.Tweet = new Post();
         // tweet.Imgs = new HttpPostedFileBase();
         tweet.Tweet.author = Session["UserId"].ToString();
         return(View("Writer", tweet));
     }
 }