コード例 #1
0
 public PointsMemeViewModel GetPointsMeme(MemeModel meme)
 => new PointsMemeViewModel
 {
     MemeId    = meme.Id,
     Points    = meme.Points,
     SComments = _gagDb.Comments.Where(c => c.MemeId == meme.Id).Count()
 };
コード例 #2
0
        public ActionResult Save(MemeModel memeModel)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new MemeViewModel()
                {
                    MemeModel  = memeModel,
                    Categories = _context.Categories
                };

                return(View("CreateMeme", viewModel));
            }

            if (memeModel.Id == 0)
            {
                memeModel.CreatedBy = User.Identity.GetUserName();
                memeModel.Likes     = 0;
                memeModel.AddedDate = DateTime.Now;
                _context.MemeModels.Add(memeModel);
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: AnkoBG/KEKChat
        public ActionResult BuyMeme(MemeModel meme, int buy)
        {
            if (ModelState.IsValid)
            {
                KEKCore.Store.BuyMeme(meme.AssetName, meme.Quantity, buy, User.Identity.Name);
            }

            return(this.Store());
        }
コード例 #4
0
        public HttpResponseMessage Post([FromBody] MemeModel memeModel)
        {
            IMeme meme = new Meme
            {
                CreatedByUserId = User.Identity.UserId(),
                CreatedBy       = User.Identity.Name,
                DateCreated     = DateTime.Now.ToUniversalTime(),
                SeedId          = memeModel.SeedId,
                Comments        = memeModel.Comments.Select(x => (IComment) new Comment
                {
                    Id = x.Id,
                    BackgroundColor = x.BackgroundColor,
                    Color           = x.Color,
                    FontFamily      = x.FontFamily,
                    FontSize        = x.FontSize,
                    FontStyle       = x.FontStyle,
                    FontWeight      = x.FontWeight,
                    Position        = new PositionRef
                    {
                        Align  = x.Position.Align,
                        X      = x.Position.X,
                        Y      = x.Position.Y,
                        Width  = x.Position.Width,
                        Height = x.Position.Height
                    },
                    Text           = x.Text,
                    TextAlign      = x.TextAlign,
                    TextDecoration = x.TextDecoration,
                    TextShadow     = x.TextShadow,
                }).ToList(),
                ImageData    = Convert.FromBase64String(memeModel.ImageData),
                ResponseToId = memeModel.ResponseToId,
                ReplyIds     = new List <IReply>(),
                HashTags     = memeModel.HashTags ?? new List <string>()
            };

            //save the meme
            meme = memeBusiness.SaveMeme(meme);

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, meme);

            response.Headers.Location = new Uri(Request.RequestUri, "/api/meme/" + meme.Id);
            return(response);
        }
コード例 #5
0
 public string CreateMeme([FromForm] MemeModel meme)
 {
     if (ModelState.IsValid)
     {
         List <MemeModel> foundMemes = context.Memes.Where(m => m.ImageSource == meme.ImageSource).ToList();
         if (foundMemes.Count > 0)
         {
             if (!foundMemes[0].Tag.Contains(meme.Tag))
             {
                 foundMemes[0].Tag += meme.Tag;
             }
         }
         else
         {
             context.Memes.Add(meme);
         }
         context.SaveChanges();
         return("Ну добавил и добавил мем, что бухтеть то");
     }
     else
     {
         return("Мем не добавлен, введите корректные значения для ссылки и тэгов");
     }
 }
コード例 #6
0
 public MemePresenter()
 {
     model = new MemeModel();
 }