public async Task <IActionResult> Create([Bind("IdGym,Name,City,Address,WorkingHours,Contact")] Gym gym) { if (ModelState.IsValid) { _context.Add(gym); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(gym)); }
public async Task <IActionResult> Create([Bind("IdMembershipPlan,Name,Description")] MembershipPlan membershipPlan) { if (ModelState.IsValid) { _context.Add(membershipPlan); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(membershipPlan)); }
public async Task <IActionResult> Create([FromBody] Client client) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } context.Clients.Add(client); await context.SaveChangesAsync(); return(CreatedAtAction("GetClient", new { id = client.ID }, client)); }
public async Task <IActionResult> Create([Bind("IdTrainer,FirstName,LastName,DateOfBirth,Qualifications,Achievements,IdGym")] Trainer trainer) { if (ModelState.IsValid) { _context.Add(trainer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdGym"] = new SelectList(_context.Gyms, "IdGym", "Address", trainer.IdGym); return(View(trainer)); }
public async Task <IActionResult> Create([Bind("IdCustomer,FirstName,LastName,DateOfBirth,IdMembershipPlan,IdGym")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdGym"] = new SelectList(_context.Gyms, "IdGym", "Address", customer.IdGym); ViewData["IdMembershipPlan"] = new SelectList(_context.MembershipPlans, "IdMembershipPlan", "Description", customer.IdMembershipPlan); return(View(customer)); }
public Task Save() { return(context.SaveChangesAsync()); }