Ejemplo n.º 1
0
        public ActionResult Login(string email, string password)
        {
            if (Membership.ValidateUser(email, password))
            {
                FormsAuthentication.SetAuthCookie(email, false);

                if (email.Contains("@alkoshop.com"))
                {
                    EmployeeDao employeeDao            = new EmployeeDao();
                    DataAccess.Model.Employee employee = employeeDao.GetByEmailAndPassword(email, password);
                    Session["User"]     = employee;
                    Session["UserRole"] = "Employee";
                }
                else
                {
                    CustomerDao customerDao            = new CustomerDao();
                    DataAccess.Model.Customer customer = customerDao.GetByEmailAndPassword(email, password);
                    Session["User"]     = customer;
                    Session["UserRole"] = "Customer";
                }
                return(RedirectToAction("Index", "Home", new { area = Session["UserRole"] }));
            }

            TempData["login-error"] = "Login nebo heslo není správné";
            return(RedirectToAction("Index", "Login"));
        }
 public ActionResult Create(Address address)
 {
     DataAccess.Model.Employee employee = new DataAccess.Model.Employee();
     employee.Address             = TempData["tempAddress"] as Address;
     TempData["addresscontainer"] = employee.Address;
     return(View());
 }
        public ActionResult Add(DataAccess.Model.Employee employee)
        {
            var addressContainer = TempData["addresscontainer"];

            if (employee.Address == null)
            {
                if (TempData["addresscontainer"] == null)
                {
                    return(RedirectToAction("Create", "Address", new{ area = "" }));
                }
                employee.Address = (Address)TempData["addresscontainer"];
            }
            if (ModelState.IsValid)
            {
                EmployeeDao employeeDao = new EmployeeDao();
                employeeDao.Create(employee);
                TempData["message-success"] = "Employee was added successfully";

                return(RedirectToAction("Index", "Home"));
            }


            return(View("Create", employee));
        }