public void Add(Register newUser, string origin) { if (_dbcontext.Users.Any(x => x.Email == newUser.Email)) { // send already registered error in email to prevent account enumeration sendAlreadyRegisteredEmail(newUser.Email, origin); return; } var user = new User { FirstName = newUser.FirstName, LastName = newUser.LastName, DOB = newUser.DOB, Email = newUser.Email, Password = newUser.Password, Gender = newUser.Gender, TelNo = newUser.TelNo, FitnessPackage = this.GetFitnessPackage(newUser.FitnessPackage), NutritionPackage = GetNutritionPackage(newUser.NutritionPackage), Created = DateTime.UtcNow, VerificationToken = randomTokenString() }; _dbcontext.Add(user); _dbcontext.SaveChanges(); sendVerificationEmail(user, origin); }
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)); }
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)); }
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,FirstName,LastName,Bdate,Adr,Password,Email,Number")] Trainer trainer) { if (ModelState.IsValid) { _context.Add(trainer); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } return(View()); }
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 void AddScedule(FitnessSchedule fitnessSchedule) { _context.Add(fitnessSchedule); _context.SaveChanges(); }