Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            //var obj = _roleGroupService.GetRoleGroupById(id);
            //return View(obj);
            if (Session["role"] == null)
            {
                return(Redirect("/Dashboard/Index"));
            }
            var session = Session["role"].ToString().ToLower();

            if (session.Equals("super user"))
            {
                var obj = _roleGroupService.GetRoleGroupById(id);
                return(View(obj));
            }
            else
            {
                return(Redirect("/Dashboard/Index"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Login(LoginFormModel item)
        {
            //Session["role"] = _roleGroupService.GetRoleGroupById(item.RoleGroupId).GroupName;
            //Session["wwid"] = item.WWID;
            //Session["mail"] = item.mail;
            //Session["ManagerWWID"] = item.ManagerWWID;



            var role = _roleGroupService.GetRoleGroupById(item.RoleGroupId).GroupName;
            var wwid = item.WWID;

            if (!role.ToString().ToLower().Equals("requestor"))
            {
                if (role.ToString().ToLower().Equals("requestor manager"))
                {
                    var listInv = _invoiceService.GetAllInvoices();
                    foreach (var obj in listInv)
                    {
                        var manager = obj.Note.ToString().Split('|').LastOrDefault();
                        if (item.WWID.ToString().Equals(manager))
                        {
                            Session["role"]        = _roleGroupService.GetRoleGroupById(item.RoleGroupId).GroupName;
                            Session["wwid"]        = item.WWID;
                            Session["mail"]        = item.mail;
                            Session["ManagerWWID"] = item.ManagerWWID;
                            return(RedirectToAction("Index"));
                        }
                    }
                    return(RedirectToAction("Index"));
                }



                var roleOfUser = _userTableService.GetAllUsers().Where(p => p.WWID.ToString().Equals(wwid.ToString())).FirstOrDefault();
                if (roleOfUser != null)
                {
                    var roleName = _roleGroupService.GetAllRoleGroups().Where(p => p.Id == roleOfUser.RoleGroupId).FirstOrDefault().GroupName;
                    if (role.ToString().Equals(roleName.ToString()))
                    {// right role
                        Session["role"]        = _roleGroupService.GetRoleGroupById(item.RoleGroupId).GroupName;
                        Session["wwid"]        = item.WWID;
                        Session["mail"]        = item.mail;
                        Session["ManagerWWID"] = item.ManagerWWID;
                        return(RedirectToAction("Index"));
                    }
                    else
                    {// wrong role
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {// the user is requestor, return login page with alert
                    return(RedirectToAction("Index"));
                }
            }



            Session["role"]        = _roleGroupService.GetRoleGroupById(item.RoleGroupId).GroupName;
            Session["wwid"]        = item.WWID;
            Session["mail"]        = item.mail;
            Session["ManagerWWID"] = item.ManagerWWID;
            Session["listItem"]    = null;
            Session["option"]      = null;
            return(RedirectToAction("Index"));
        }