コード例 #1
0
        public ActionResult Login(CustomerModel model)
        {
            try
            {
                var result = CustomerCRUD.CustomerLogin(model.Email, model.Password);

                if (result.Count() > 0)
                {
                    Session["FullName"] = result[0].FirstName + " " + result[0].LastName;
                    Session["idUser"]   = result[0].Id;

                    return(RedirectToAction("Index", "Menu"));
                }
                else
                {
                    ViewBag.error = "Login failed";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ExceptionLogDomain obj = new ExceptionLogDomain();
                obj.MethodName     = "Login";
                obj.ControllerName = "Customer";
                obj.ErrorText      = ex.Message;
                obj.StackTrace     = ex.StackTrace;
                obj.Datetime       = DateTime.Now;

                ExceptionLogCRUD.AddToExceptionLog(obj);
                return(RedirectToAction("Index", "Error"));
            }
        }