private void SetViewByUserRole(ActionExecutingContext filterContext, HttpSessionStateBase session)
        {
            if (session["UserID"] != null && session["UserName"] != null && session["RoleID"] != null && session["RoleName"] != null)
            {
                bool        bIsValidUser = false;
                bool        bIsValidRole = false;
                Models.User oUser        = null;
                Models.Role oRole        = null;
                try
                {
                    oUser = new Models.User();
                    List <Models.User> oUserList = oUser.GetUserInformation(Convert.ToInt64(session["UserID"]), "ONE");
                    if (oUserList.Count == 1)
                    {
                        bIsValidUser = true;
                    }
                    oRole = new Models.Role();
                    List <Models.Role> oRoleList = oRole.GetAllRoles(Convert.ToInt64(session["RoleID"]), "ONE");
                    if (oRoleList.Count == 1)
                    {
                        bIsValidRole = true;
                    }

                    if (bIsValidUser)
                    {
                        if (bIsValidRole)
                        {
                            switch (Convert.ToString(session["RoleName"]))
                            {
                            case "Super Admin":
                                filterContext.Controller.ViewData["Dashboard"]       = "normal";
                                filterContext.Controller.ViewData["ManageAircraft"]  = "normal";
                                filterContext.Controller.ViewData["ManageAirline"]   = "normal";
                                filterContext.Controller.ViewData["StandData"]       = "normal";
                                filterContext.Controller.ViewData["AssociationData"] = "normal";
                                break;

                            case "Admin":
                                filterContext.Controller.ViewData["Dashboard"]       = "normal";
                                filterContext.Controller.ViewData["ManageAircraft"]  = "normal";
                                filterContext.Controller.ViewData["ManageAirline"]   = "normal";
                                filterContext.Controller.ViewData["StandData"]       = "normal";
                                filterContext.Controller.ViewData["AssociationData"] = "normal";
                                break;

                            case "User":
                                filterContext.Controller.ViewData["Dashboard"]       = "normal";
                                filterContext.Controller.ViewData["ManageAircraft"]  = "normal";
                                filterContext.Controller.ViewData["ManageAirline"]   = "normal";
                                filterContext.Controller.ViewData["StandData"]       = "normal";
                                filterContext.Controller.ViewData["AssociationData"] = "normal";
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    if (oUser != null)
                    {
                        oUser.Dispose();
                        oUser = null;
                    }
                    if (oRole != null)
                    {
                        oRole.Dispose();
                        oRole = null;
                    }
                }
            }
        }
Exemple #2
0
        public ActionResult Delete(Int64 nID, string sType, string sActionName, string sControllerName)
        {
            string Message = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    int nStatus = 0;
                    if (nID != 0)
                    {
                        switch (sType)
                        {
                        case "User":
                        {
                            Models.User oUser = new Models.User();
                            nStatus = oUser.DeleteUser(nID, "DELETE");
                            if (oUser != null)
                            {
                                oUser.Dispose();
                                oUser = null;
                            }
                            break;
                        }

                        case "Aircraft":
                        {
                            Models.Aircraft oAircraft = new Models.Aircraft();
                            nStatus = oAircraft.DeleteAircraft(nID, "DELETE");
                            if (oAircraft != null)
                            {
                                oAircraft.Dispose();
                                oAircraft = null;
                            }
                            break;
                        }

                        case "Airline":
                        {
                            Models.Airline oAirline = new Models.Airline();
                            nStatus = oAirline.DeleteAirline(nID, "DELETE");
                            if (oAirline != null)
                            {
                                oAirline.Dispose();
                                oAirline = null;
                            }
                            break;
                        }

                        case "BME": { break; }

                        case "Stand": { break; }

                        case "Assocciation": { break; }
                        }
                    }
                    switch (nStatus)
                    {
                    case -1: ViewBag.Message = sType + " information already exists";
                        break;

                    case 1: ViewBag.Message = "Error";
                        break;

                    case 3: ViewBag.Message = sType + " information deleted successfully";
                        break;
                    }
                }
                ViewBag.Action         = sActionName;
                ViewBag.ControllerName = sControllerName;
            }
            catch (Exception ex)
            {
            }
            return(View());
        }