Ejemplo n.º 1
0
        public IActionResult submittingAddtional(string Activity_Lev, string Preferences, bool IsAllergic, string Allergies, bool IsVeg)
        {
            var       username   = HttpContext.Session.GetString("Username");
            Allergies addAllergy = new Allergies();

            addAllergy.RecordId      = Guid.NewGuid();
            addAllergy.UserName      = username;
            addAllergy.IsAllergic    = IsAllergic;
            addAllergy.AllergiesList = Allergies;
            //allergyList
            db.Add(addAllergy);

            Preferences AddPreferences = new Preferences();

            AddPreferences.RecordId        = Guid.NewGuid();
            AddPreferences.Username        = username;
            AddPreferences.PreferencesList = Preferences;
            db.Add(AddPreferences);

            double?TDEE = 0;
            var    user = db.ProgressTracker.Where(x => x.UserName.ToLower() == username.ToLower()).FirstOrDefault();

            user.ActivityLevel = Activity_Lev;

            switch (Activity_Lev)
            {
            case "sedentary": TDEE = user.Bmr * 1.2; break;

            case "lightly": TDEE = user.Bmr * 1.375; break;

            case "mild": TDEE = user.Bmr * 1.55; break;

            case "very": TDEE = user.Bmr * 1.725; break;

            case "extra": TDEE = user.Bmr * 1.9; break;
            }

            user.Tdee = (double)TDEE;
            db.Update(user);
            var dietuser = db.DietUsers.Find(username);

            dietuser.NewUser = false;
            db.Update(dietuser);

            db.SaveChanges();
            return(RedirectToAction("Dashboard"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,servqty,serv,group,food")] FoodDb foodDb)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(foodDb);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(foodDb));
            }
            catch (SqlException)
            {
                string action     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controller = this.ControllerContext.RouteData.Values["controller"].ToString();
                return(RedirectToAction("Error", "Admin", new { controllerName = controller, actionName = action }));
            }
        }
        public async Task <IActionResult> Create([Bind("AdminUsername,AdminPassword,AdminName")] AdminsTable adminsTable)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    adminsTable.Status = "Active";
                    _context.Add(adminsTable);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(adminsTable));
            }
            catch (SqlException)
            {
                string action     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controller = this.ControllerContext.RouteData.Values["controller"].ToString();
                return(RedirectToAction("Error", "Admin", new { controllerName = controller, actionName = action }));
            }
        }