예제 #1
0
        public async Task <IActionResult> Create([Bind("UserId,CreationDate,EmailAddress,Enabled,LastLoginDate,LastLoginIp,ModificationDate,Name,Password,PasswordRecoveryAnswer,PasswordRecoveryQuestion")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("FoodId,Calories,Carbs,DayId,Fats,Name,Proteins,UserId")] Food food)
        {
            food.CreationDate     = DateTime.Now;
            food.ModificationDate = DateTime.Now;

            if (ModelState.IsValid)
            {
                _context.Add(food);
                await _context.SaveChangesAsync();

                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));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("NoteId,NoteDate,NoteText,NoteType,NoteTypeId,UserId")] Note note)
        {
            note.CreationDate     = DateTime.Now;
            note.ModificationDate = DateTime.Now;

            if (ModelState.IsValid)
            {
                _context.Add(note);
                await _context.SaveChangesAsync();

                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));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("DayId,UserId")] Day day)
        {
            day.CreationDate     = DateTime.Now;
            day.ModificationDate = DateTime.Now;
            day.EntryDate        = DateTime.Now;

            if (ModelState.IsValid)
            {
                _context.Add(day);
                await _context.SaveChangesAsync();

                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));
        }
예제 #5
0
        public async Task <IActionResult> Create([Bind("ExerciseId,DayId,ExerciseType,ExerciseName,Reps,Sets,UnitType,UserId,Weight")] Exercise exercise)
        {
            exercise.CreationDate     = DateTime.Now;
            exercise.ModificationDate = DateTime.Now;

            if (ModelState.IsValid)
            {
                _context.Add(exercise);
                await _context.SaveChangesAsync();

                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));
        }