Example #1
0
        public async Task <IActionResult> EditProfile(int id, [Bind("Id,FName,LName,Birthdate,MainGoal,Password,PhoneNumber,Email,Career,Height,Weight,Adress")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(""));
            }
            AppUser user1 = await userManager.GetUserAsync(User);

            if (id != user1.UserId)
            {
                return(RedirectToAction("AccessDenied", "Account", null));
            }
            return(View(user1));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Duration,Equipment,Description,Price")] Programme programme)
        {
            if (id != programme.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(programme);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProgrammeExists(programme.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(programme));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,EName,EImage")] Exrecise exrecise)
        {
            if (id != exrecise.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(exrecise);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExreciseExists(exrecise.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(exrecise));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Breakfast,Lunch,Dinner,Snacks")] DietPlan dietPlan)
        {
            if (id != dietPlan.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dietPlan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DietPlanExists(dietPlan.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dietPlan));
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Ingredients,Directions")] Recipe recipe)
        {
            if (id != recipe.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(recipe);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RecipeExists(recipe.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipe));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,TrainerId,DietPlanId,StartDate,EndDate")] Enrollment enrollment)
        {
            if (id != enrollment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentExists(enrollment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }