Ejemplo n.º 1
0
        public ActionResult Login(User user)
        {
            if (ModelState.IsValid)
            {
                if (ValidateUser.IsValid(user.Username, user.Password) != null)
                {
                    var userDisplay = ValidateUser.IsValid(user.Username, user.Password);
                    Session["log"]        = userDisplay.Username;
                    Session["typeEntity"] = userDisplay.Type;
                    Session["userID"]     = userDisplay.UserId;
                    switch (userDisplay.Type)
                    {
                    case "student": return(RedirectToAction("Index", "Student"));

                    case "teacher": return(RedirectToAction("Index", "Teacher"));

                    case "admin": return(RedirectToAction("Index", "Admin"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Login data is incorrect!");
                }
            }
            return(View(user));
        }
Ejemplo n.º 2
0
 public ActionResult EditProfile(User user)
 {
     if (ValidateUser.IsValid(user))
     {
         ServiceFactory.GetUserServices().Update(user);
         return(RedirectToAction("UserProfile"));
     }
     else
     {
         ViewBag.Error = null;
         ViewBag.Error = ValidateUser.Message;
         return(View());
     }
 }
Ejemplo n.º 3
0
        public ActionResult CreateOwner(User u)
        {
            if (ValidateUser.IsValid(u))
            {
                u.UserType = ServiceFactory.GetUserTypeServices().Get("Owner").Id;
                Company c = (Company)Session["Company"];
                ServiceFactory.GetCompanyServices().Insert(c);
                u.CompanyId = c.Id;

                ServiceFactory.GetUserServices().Insert(u);
                return(RedirectToAction("Index", "Company"));
            }
            else
            {
                ViewBag.Error = null;
                ViewBag.Error = ValidateUser.Message;
                return(View());
            }
        }