public async Task <IActionResult> Edit(int id, [Bind("IdGym,Name,City,Address,WorkingHours,Contact")] Gym gym) { if (id != gym.IdGym) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gym); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GymExists(gym.IdGym)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gym)); }
public async Task <IActionResult> Edit(int id, [Bind("IdMembershipPlan,Name,Description")] MembershipPlan membershipPlan) { if (id != membershipPlan.IdMembershipPlan) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(membershipPlan); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MembershipPlanExists(membershipPlan.IdMembershipPlan)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(membershipPlan)); }
public async Task <IActionResult> Edit(int id, [Bind("IdCustomer,FirstName,LastName,DateOfBirth,IdMembershipPlan,IdGym")] Customer customer) { if (id != customer.IdCustomer) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(customer.IdCustomer)) { return(NotFound()); } else { throw; } } 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 async Task <IActionResult> Edit(int id, [Bind("IdTrainer,FirstName,LastName,DateOfBirth,Qualifications,Achievements,IdGym")] Trainer trainer) { if (id != trainer.IdTrainer) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(trainer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrainerExists(trainer.IdTrainer)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdGym"] = new SelectList(_context.Gyms, "IdGym", "Address", trainer.IdGym); return(View(trainer)); }
public async Task <IActionResult> MarkVisiting([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var client = context.Clients.Find(id); if (client == null) { return(NotFound()); } var lastVisiting = client.Visitings.LastOrDefault(); if (lastVisiting != null && lastVisiting.FinishTime == null) { client.Visitings.LastOrDefault().FinishTime = client.Visitings.LastOrDefault().StartTime.Date.AddHours(23); } Visiting visiting = new Visiting { StartTime = DateTime.Now, FinishTime = null }; client.Visitings.Add(visiting); context.Update(client); try { await context.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); } return(Ok()); }