public PointsMemeViewModel GetPointsMeme(MemeModel meme) => new PointsMemeViewModel { MemeId = meme.Id, Points = meme.Points, SComments = _gagDb.Comments.Where(c => c.MemeId == meme.Id).Count() };
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")); }
public ActionResult BuyMeme(MemeModel meme, int buy) { if (ModelState.IsValid) { KEKCore.Store.BuyMeme(meme.AssetName, meme.Quantity, buy, User.Identity.Name); } return(this.Store()); }
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); }
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("Мем не добавлен, введите корректные значения для ссылки и тэгов"); } }
public MemePresenter() { model = new MemeModel(); }