public async Task<ActionResult> Create(Club club) { if (ModelState.IsValid) { club.AssignValues(); club.CreatedOn = DateTime.Now; club.Deleted = false; db.Clubs.Add(club); await db.SaveChangesAsync(); if (Request.UrlReferrer != null) return Redirect(Request.UrlReferrer.AbsoluteUri); return RedirectToAction("Index"); } return View(club); }
public async Task<ActionResult> Create(Player player) { if (ModelState.IsValid) { club = db.Users.Find(User.Identity.GetUserId()).Club; player.Deleted = false; player.CreatedOn = DateTime.Now; player.Club = club; db.Players.Add(player); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(player); }
public async Task<PartialViewResult> AddPlayer(Player model) { if (ModelState.IsValid) { club = db.Users.Find(User.Identity.GetUserId()).Club; model.Club = club; model.CreatedOn = DateTime.Now; model.Deleted = false; db.Players.Add(model); await db.SaveChangesAsync(); } return PartialView("_InsertPlayer", model); }
public async Task<string> CreateNG(Player model) { if (!ModelState.IsValid) return null; if (string.IsNullOrEmpty(model.FirstName)) return null; if (model.LastName == null) model.LastName = string.Empty; club = db.Users.Find(User.Identity.GetUserId()).Club; model.Club = club; model.CreatedOn = DateTime.Now; model.Deleted = false; db.Players.Add(model); await db.SaveChangesAsync(); return JsonConvert.SerializeObject(model.GetJSONPlayer(), Formatting.None); }