public ActionResult LoginRequest(string UName, string Pass, string Captcha) { try { string res = "Sussess"; if (Captcha.ToLower() != ((MFCaptcha)Session[MFSessions.CAPTCHA_KEY]).TextValue.ToLower()) { res = "کد امنیتی صحیح نیست"; } else { B_Personels bPersonel = new B_Personels(); M_Personels us = bPersonel.GetPersonels(UName, Pass); if (us == null) { res = "نام کاربری یا گذرواژه صحیح نیست"; } else { HttpCookie Coki = new HttpCookie(MFCookies.USER_KEY); Coki.Value = us.UnicKey.ToString(); Coki.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(Coki); } } return(Content(res)); } catch (Exception ex) { throw ex; } }
public ActionResult Index() { B_Personels bPersonel = new B_Personels(); ViewBag.Roles = new B_PersonelRoles().GetPersonelRoles(); return(View(bPersonel.GetPersonels().Where(c => c.Id != CurrentUser.Id).ToList())); }
public ActionResult ShowDetails(int Id, bool FromNew) { var route = new List <MFRoute> { new MFRoute { ActionName = "Index", ControllerName = "ServicesRequests", Title = "لیست درخواست ها", Priority = 1 } }; if (FromNew) { route.Add(new MFRoute { ActionName = "NewRequests", ControllerName = "ServicesRequests", Title = "درخوات های جدید", Priority = 2 }); } ViewBag.Route = route; var requst = new B_ServicesRequests().GetFullServicesRequests(Id); if (requst == null) { return(RedirectToAction("Index")); } if (requst.PersonelId.HasValue) { requst.ResponsiblePersonel = new B_Personels().GetPersonelById(requst.PersonelId.Value); } ViewBag.UserList = new B_ServicesRequestItems().GetItems(requst.Id, E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER); ViewBag.PersonelList = new B_ServicesRequestItems().GetItems(requst.Id, E_PublicCategory.SYSTEM_USER_TYPE.PERSONEL); B_Personels bPersonel = new B_Personels(); if (requst.ResponsiblePersonel != null) { ViewBag.DriverList = bPersonel.GetPersonels().Where(c => c.PersonelType == (requst.Pouriya_Type == "BOOTH" ? E_PublicCategory.PERSONEL_TYPE.SUM_CENER : E_PublicCategory.PERSONEL_TYPE.DRIVER) && c.Id != requst.ResponsiblePersonel.Id).ToList(); } else { ViewBag.DriverList = bPersonel.GetPersonels().Where(c => c.PersonelType == (requst.Pouriya_Type == "BOOTH" ? E_PublicCategory.PERSONEL_TYPE.SUM_CENER : E_PublicCategory.PERSONEL_TYPE.DRIVER)).ToList(); } return(View(requst)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.HttpContext.Request.Cookies[MFCookies.BOOTH_RIDER_KEY] != null) { string key = filterContext.HttpContext.Request.Cookies[MFCookies.BOOTH_RIDER_KEY].Value; M_Personels user = null; var ub = new B_Personels(); try { user = ub.GetPersonels(key); } catch { } if (user != null) { return; } } filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Default", action = "Login", area = "Booth" })); filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); }
/// <summary> /// آدرس اتصال به SignalR /// </summary> // protected string SignalRUrl = System.Configuration.ConfigurationManager.AppSettings["SignalRUrl"]; public BaseController() { if (System.Web.HttpContext.Current.Request.Cookies[MFCookies.USER_KEY] != null) { M_PersonelRoles role = null; string key = System.Web.HttpContext.Current.Request.Cookies[MFCookies.USER_KEY].Value; B_Personels ub = new B_Personels(); CurrentUser = ub.GetPersonels(key); if (CurrentUser == null) { return; } B_PersonelRoles ru = new B_PersonelRoles(); role = ru.GetPersonelRoles(CurrentUser.PersonelRoleId); if (role == null) { return; } ViewBag.LayoutPersonel = CurrentUser; ViewBag.LayoutPersonelRole = role; ViewBag.LayoutNewRequestCount = new B_ServicesRequests().GetServicesRequestsCount(E_PublicCategory.REQUEST_STATUS.NEW_REQUEST); ViewBag.LayoutNewRedrawalCount = new B_UserPayment().GetPaymentCuontByStatus(E_PublicCategory.PAYMENT_STATUS.NEW); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { M_Personels user = null; M_PersonelRoles role = null; List <M_PersonelRoleValues> roleValue = null; if (filterContext.HttpContext.Request.Cookies[MFCookies.USER_KEY] != null) { string key = filterContext.HttpContext.Request.Cookies[MFCookies.USER_KEY].Value; B_Personels ub = new B_Personels(); try { user = ub.GetPersonels(key); } catch { } if (user == null) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Login", action = "Index", area = "Admin" })); filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); } else { B_PersonelRoles ru = new B_PersonelRoles(); role = ru.GetPersonelRoles(user.PersonelRoleId); if (role == null) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Dashboard", action = "NoPermission", area = "Admin" })); filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); } if (role.HasFullControl == true) { return; } B_PersonelRoleValues bRoleValue = new B_PersonelRoleValues(); roleValue = bRoleValue.GetPersonelRoleValues(role.Id); if (roleValue == null || roleValue.Count == 0) { if (role == null) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Dashboard", action = "NoPermission", area = "Admin" })); filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); } } var rd = filterContext.HttpContext.Request.RequestContext.RouteData; string currentAction = rd.GetRequiredString("action"); string currentController = rd.GetRequiredString("controller") + "Controller"; Assembly asm = Assembly.GetAssembly(typeof(Global)); var action = asm.GetTypes() .Where(type => typeof(System.Web.Mvc.Controller).IsAssignableFrom(type) && type.Namespace.Contains("Shahrdari.WebApplication.Areas.Admin.Controllers")) .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public)) .Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any() && m.DeclaringType.Name == currentController && m.Name == currentAction) .Select(x => new { Attributes = x.GetCustomAttributes().ToList() }).FirstOrDefault(); if (action != null && action.Attributes.Where(c => c.GetType().Name.ToUpper().IndexOf("HTTPPOST") != -1).Count() > 0) { return; } if (roleValue.Where(c => c.AccessName.ToUpper() == (currentController + " | " + currentAction).ToUpper()).Count() == 0) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Dashboard", action = "NoPermission", area = "Admin" })); filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); } } } else { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Login", action = "Index", area = "Admin" })); filterContext.Result.ExecuteResult(filterContext.Controller.ControllerContext); } }