예제 #1
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var user = await _context.User.FindAsync(id);

            _context.User.Remove(user);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,FName,LName,Birthdate,MainGoal,PhoneNumber,Password,Email,Career,Height,Weight,Adress")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Duration,Equipment,Description,Price")] Programme programme)
        {
            if (ModelState.IsValid)
            {
                _context.Add(programme);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(programme));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,Breakfast,Lunch,Dinner,Snacks")] DietPlan dietPlan)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dietPlan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dietPlan));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("Id,Name,Ingredients,Directions")] Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipe);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipe));
        }
        public async Task <IActionResult> Create([Bind("Id,UserId,TrainerId,DietPlanId,StartDate,EndDate")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enrollment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DietPlanId"] = new SelectList(_context.Set <DietPlan>(), "Id", "Id", enrollment.DietPlanId);
            ViewData["TrainerId"]  = new SelectList(_context.Trainer, "Id", "FirstName", enrollment.TrainerId);
            ViewData["UserId"]     = new SelectList(_context.User, "Id", "FName", enrollment.UserId);
            return(View(enrollment));
        }
        public async Task <IActionResult> Create(ExreciseViewModel model)
        {
            if (ModelState.IsValid)
            {
                string   uniqueFileName = UploadedFile(model);
                Exrecise exrecise       = new Exrecise
                {
                    EName  = model.EName,
                    EImage = uniqueFileName,
                };
                _context.Add(exrecise);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Bdate,Adr,Password,Email,Number")] Trainer trainer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(trainer);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }