public bool AddNewAvatar(AvatarEntity avatar) { if (AddFruitToAvatar(avatar) != null) { if (!Exist(avatar.CurrentIP)) { _ctx.Add(avatar); return(Save()); } } return(false); }
public async Task <IActionResult> Create([Bind("Id,Name,Path")] Photo photo) { if (ModelState.IsValid) { _context.Add(photo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(photo)); }
public async Task <IActionResult> Create([Bind("Id,Login,City")] User user) { if (ModelState.IsValid) { context.Add(user); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create(ContentType contentType) { if (ModelState.IsValid) { _context.Add(contentType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(contentType)); }
public async Task <IActionResult> Create([Bind("Id,Name,UserId,ContentTypeId")] Content content) { if (ModelState.IsValid) { _context.Add(content); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContentTypeId"] = new SelectList(_context.ContentTypes, "Id", "Id", content.ContentTypeId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Login", content.UserId); return(View(content)); }
public async Task <IActionResult> Create([Bind("Id,ContentId,UserId,Rating")] UsersRating usersRating) { if (ModelState.IsValid) { _context.Add(usersRating); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContentId"] = new SelectList(_context.Contents, "Id", "Discriminator", usersRating.ContentId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Login", usersRating.UserId); return(View(usersRating)); }
public bool AddOrRemoveFlag(FlagEntity flag, int userId = 0) { if (userId == 0) { using (var context = new ContentContext()) { context.Add(flag); return(context.SaveChanges() > 0); } // _ctx.Add(flag); } if (userId > 0) { using (var context = new ContentContext()) { context.Remove(flag); return(context.SaveChanges() > 0); } // _ctx.Remove(flag); } return(Save()); }
public bool AddOrRemoveVote(VoteEntity vote, int guestId = 0) { if (guestId > 0) { using (var context = new ContentContext()) { context.Remove(vote); return(context.SaveChanges() > 0); } //_ctx.Remove<VoteEntity>(Upvote); } if (guestId == 0) { using (var context = new ContentContext()) { context.Add(vote); return(context.SaveChanges() > 0); } //_ctx.Add<VoteEntity>(Upvote); } return(Save()); }