Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ExerciseId,CreationDate,DayId,ExerciseType,ExerciseName,ModificationDate,Reps,Sets,UnitType,UserId,Weight")] Exercise exercise)
        {
            if (id != exercise.ExerciseId)
            {
                return(NotFound());
            }

            exercise.ModificationDate = DateTime.Now;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(exercise);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExerciseExists(exercise.ExerciseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["DayId"]        = new SelectList(_context.Days, "DayId", "DayId", exercise.DayId);
            ViewData["UserId"]       = new SelectList(_context.Users, "UserId", "Name", exercise.UserId);
            ViewData["ExerciseType"] = new SelectList(EntityHelper.GetConstants(typeof(EntityHelper.ExerciseTypes)), exercise.ExerciseType);
            ViewData["UnitType"]     = new SelectList(EntityHelper.GetConstants(typeof(EntityHelper.UnitTypes)), exercise.UnitType);
            return(View(exercise));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,CreationDate,EmailAddress,Enabled,LastLoginDate,LastLoginIp,ModificationDate,Name,Password,PasswordRecoveryAnswer,PasswordRecoveryQuestion")] User user)
        {
            if (id != user.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("FoodId,Calories,Carbs,CreationDate,DayId,Fats,ModificationDate,Name,Proteins,UserId")] Food food)
        {
            if (id != food.FoodId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(food);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FoodExists(food.FoodId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["DayId"]  = new SelectList(_context.Days, "DayId", "DayId", food.DayId);
            ViewData["UserId"] = new SelectList(_context.Users, "UserId", "Name", food.UserId);
            return(View(food));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("NoteId,CreationDate,ModificationDate,NoteDate,NoteText,NoteType,NoteTypeId,UserId")] Note note)
        {
            if (id != note.NoteId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(note);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoteExists(note.NoteId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["UserId"]   = new SelectList(_context.Users, "UserId", "Name", note.UserId);
            ViewData["NoteType"] = new SelectList(EntityHelper.GetConstants(typeof(EntityHelper.NoteTypes)), note.NoteType);
            return(View(note));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("DayId,CreationDate,EntryDate,ModificationDate,UserId")] Day day)
        {
            if (id != day.DayId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(day);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DayExists(day.DayId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "UserId", "Name", day.UserId);
            ViewData["DayId"]  = new SelectList(_context.Days, "DayId", "DayId", day.DayId);
            return(View(day));
        }