예제 #1
0
        public ActionResult Register(TBLCustomer User)
        {
            BMI bmi = new BMI();

            // try
            //{
            if (ModelState.IsValid)
            {
                if (User.Height != null && User.Weight != null)
                {
                    User.BMI = bmi.CalculateBMI(User.Height, User.Weight);
                }
                else
                {
                    User.BMI = 0;
                }
                Object.TBLCustomers.Add(User);
                Object.SaveChanges();
                TempData["msg"] = "Registration Successfully";
                return(View());
            }
            else
            {
                return(View());
            }

            // }
            // catch (Exception e)
            //{
            //TempData["msg"] = "Registration failed " + e.Message;
            //  return RedirectToAction("Register");
            // }
        }
예제 #2
0
        public ActionResult Login(TBLCustomer User)
        {
            DAERSEntities Object        = new DAERSEntities();
            var           Authorization = Object.TBLCustomers.Where(recognize => recognize.Email == User.Email && recognize.Password == User.Password).Count();

            if (Authorization > 0)
            {
                FormsAuthentication.SetAuthCookie(User.Email, false);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TempData["Login"] = "******";
                return(View());
            }
        }