Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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);
 }