コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
 public Task Save()
 {
     return(context.SaveChangesAsync());
 }