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);
        }
Example #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));
        }
Example #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));
        }
Example #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,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());
        }
Example #9
0
 public void AddScedule(FitnessSchedule fitnessSchedule)
 {
     _context.Add(fitnessSchedule);
     _context.SaveChanges();
 }