public virtual System.Threading.Tasks.Task<CoreWebApiClient.TestControllers.AnotherTestDto> GetAsync(int id, string name, string value) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("id", id); routeValues.Add("name", name); routeValues.Add("value", value); return this.HttpClientGetAsync<CoreWebApiClient.TestControllers.AnotherTestDto>("Get", routeValues); }
// // GET: /Home/ public ActionResult Index() { System.Web.Routing.RouteValueDictionary rvd = new System.Web.Routing.RouteValueDictionary(); rvd.Add("controller", "Index"); rvd.Add("action", "Index"); return RedirectToRoute("Main_Default", rvd); }
/// <summary> /// 网站语言设为美式英文 /// </summary> /// <returns>ActionResult.</returns> public ActionResult English(string returnUrl) { this.Session[SessionKey.Language] = LangEnum.EN_US; if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } System.Web.Routing.RouteValueDictionary rvd = new System.Web.Routing.RouteValueDictionary(); rvd.Add("controller", "Home"); rvd.Add("action", "Index"); return RedirectToRoute("Default", rvd); }
public LabelMenuItem(string name, string fullName, string culture) { base.Action = "index"; base.Controller = "label"; base.Area = "Sites"; base.Text = name; base.Visible = true; RouteValues = new System.Web.Routing.RouteValueDictionary(); RouteValues.Add("category", fullName); RouteValues.Add("culture", culture); this.Initializer = new LabelMenuItemInitializer(); }
public PageMenuItem(Page page) { base.Action = "Index"; base.Controller = "Page"; base.Area = "Sites"; base.Text = page.Name; if (page.Navigation != null && !string.IsNullOrEmpty(page.Navigation.DisplayText)) { base.Text = page.Navigation.DisplayText; } base.Tips = page.Name; base.Visible = true; RouteValues = new System.Web.Routing.RouteValueDictionary(); RouteValues.Add("parentPage", page.FullName); HtmlAttributes = new System.Web.Routing.RouteValueDictionary(); if (page.IsDefault) { HtmlAttributes.Add("class", "home"); } //this.Page = page; Initializer = new PageMenuItemInitializer(); }
public LanguageSpecificMenuItem(string language) { Action = "Index"; Language = language; RouteValues = new System.Web.Routing.RouteValueDictionary(); RouteValues.Add("culture", language); Initializer = new LanguageSpecificMenuItemInitializer(); }
// // GET: /User/Create public ActionResult Create() { if (!Access.HasAccess(2)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } UserNew theUser = new UserNew(); return(View(theUser)); }
public override void OnAuthorization(AuthorizationContext filterContext) { if (filterContext.HttpContext.User.Identity.IsAuthenticated) { // Call base class to allow user into the action method base.OnAuthorization(filterContext); } else { //string ReturnURL = filterContext.RequestContext.HttpContext.Request.Path.ToString(); //filterContext.Controller.TempData.Add("Warning", // $"you must be logged into any account to access this resource, you are not currently logged in at all"); //filterContext.Controller.TempData.Add("ReturnURL", ReturnURL); System.Web.Routing.RouteValueDictionary dict = new System.Web.Routing.RouteValueDictionary(); dict.Add("Controller", "User"); dict.Add("Action", "UserLogIn"); filterContext.Result = new RedirectToRouteResult(dict); } }
public override void OnAuthorization(AuthorizationContext filterContext) { // check if user is indeed in the role. if (filterContext.HttpContext.User.Identity.IsAuthenticated) { //Call base class to allow user into the action method base.OnAuthorization(filterContext); } else { // user is not Logged in. Redirect to a login page string ReturnURL = filterContext.RequestContext.HttpContext.Request.Path.ToString(); filterContext.Controller.TempData.Add("Message", $"you must be logged into some account to access this resource. You are not logged in"); filterContext.Controller.TempData.Add("ReturnURL", ReturnURL); System.Web.Routing.RouteValueDictionary dict = new System.Web.Routing.RouteValueDictionary(); dict.Add("Controller", "Home"); dict.Add("Action", "Login"); filterContext.Result = new RedirectToRouteResult(dict); } }
// // GET: /Branches/Edit/5 public ActionResult Edit(int id) { if (!AccessActions.IsAccess("Branches::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } BrancheModel model = new BrancheModel(); model.FindOne(id); return(View(model)); }
// // GET: /Area/Edit/5 public ActionResult Edit(int id) { if (!Access.HasAccess(43)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Area model = new Area(); model = model.GetById(id); return(View(model)); }
public override void OnAuthorization(AuthorizationContext filterContext) { // check if user is indeed in the role. if (this.Roles.Split(' ').Any(filterContext.HttpContext.User.IsInRole)) { //Call base class to allow user into the action method base.OnAuthorization(filterContext);; } else { // user is not in the required role. Redirect to a login page string ReturnURL = filterContext.RequestContext.HttpContext.Request.Path.ToString(); filterContext.Controller.TempData.Add("Message", $"you must be in at least one of the following roles to access this resource: {this.Roles}"); filterContext.Controller.TempData.Add("ReturnURL", ReturnURL); System.Web.Routing.RouteValueDictionary dict = new System.Web.Routing.RouteValueDictionary(); dict.Add("Controller", "Home"); dict.Add("Action", "Login"); filterContext.Result = new RedirectToRouteResult(dict); } }
public ActionResult Create(FormCollection collection) { if (!Access.HasAccess(67)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } try { Store model = new Store(); model.Name = collection["Name"]; if (collection["User.Id"] != "") { model.User = (new User()).GetById(Convert.ToInt32(collection["User.Id"])); } if (collection["User2.Id"] != "") { model.User2 = (new User()).GetById(Convert.ToInt32(collection["User2.Id"])); } if (collection["Room.ID"] != "") { model.Room = (new Room()).GetById(Convert.ToInt32(collection["Room.ID"])); } if (collection["Areas"] != null) { string[] arrayAreaIDs = collection["Areas"].Split(','); foreach (string str in arrayAreaIDs) { int areaID = Convert.ToInt32(str); HardX.Models.Area theArea = new HardX.Models.Area(); theArea = theArea.GetById(areaID); model.Areas.Add(theArea); } } model.Save(model); return(RedirectToAction("Index")); } catch (Exception ex) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", ex.Message); return(RedirectToAction("Error", "Home", route)); } }
// // GET: /User/Delete/5 public ActionResult Delete(int id) { if (!AccessActions.IsAccess("User::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "��� �������!"); return(RedirectToAction("Error", "User", route)); } UserModel user = new UserModel(); user.FindByID(id); user.Delete(); return(RedirectToAction("Index")); }
public ActionResult Create(FormCollection collection) { /* * if (!Access.HasAccess(9)) * { * System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); * route.Add("err", "Нет доступа!"); * return RedirectToAction("Error", "Capital", route); * } * */ try { // TODO: Add insert logic here Role theRole = new Role(); theRole.Name = collection["Name"]; if (collection["Actions"] != null) { string[] arrayActionID = collection["Actions"].Split(','); foreach (string str in arrayActionID) { int actionID = Convert.ToInt32(str); HardX.Models.Action theAction = new HardX.Models.Action(); theAction = theAction.GetById(actionID); theRole.Actions.Add(theAction); } } if (collection["Users"] != null) { string[] arrayUserID = collection["Users"].Split(','); foreach (string str in arrayUserID) { int userID = Convert.ToInt32(str); HardX.Models.User theUser = new HardX.Models.User(); theUser = theUser.GetById(userID); theRole.Users.Add(theUser); } } theRole.Save(theRole); return(RedirectToAction("Index")); } catch (Exception ex) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", ex.Message); return(RedirectToAction("Error", "Home", route)); } }
// // GET: /Abonents/Delete/5 public ActionResult Delete(int id) { if (!AccessActions.IsAccess("Abonents::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } AbonentModel theAbonent = new AbonentModel(); theAbonent.FindOne(id); theAbonent.Delete(); return(RedirectToAction("Index")); }
// // GET: /User/Details/5 public ActionResult Details(int id) { if (!Access.HasAccess(4)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } User theUser = new User(); theUser = theUser.GetById(id); return(View(theUser)); }
// // GET: /Abonents/Edit/5 public ActionResult Edit(int id) { if (!AccessActions.IsAccess("Abonents::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "User", route)); } AbonentModel theAbonent = new AbonentModel(); BrancheModel branch = new BrancheModel(); ViewBag.AllBranches = branch.FindAll(); return(View(theAbonent.FindOne(id))); }
public ActionResult Compatibility(int ID) { if (!Access.HasAccess(61)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Matmodel model = new Matmodel(); model = model.GetById(ID); return(View(model)); }
// // GET: /Material/Delete/5 public ActionResult Delete(int id) { if (!Access.HasAccess(60)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Material item = new Material(); item = item.GetById(id); item.Delete(item); return(View()); }
// // GET: /Region/ public ActionResult Index() { if (!Access.HasAccess(16)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Region model = new Region(); List <Region> theListModel = new List <Region>(); theListModel = (List <Region>)model.GetAll(); return(View(theListModel)); }
// // GET: /Branch/Delete/5 public ActionResult Delete(int id) { if (!Access.HasAccess(10)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Branche theBranche = new Branche(); theBranche = theBranche.GetById(id); theBranche.Delete(theBranche); return(RedirectToAction("Index")); }
// // GET: /Shipping/Delete/5 public ActionResult Delete(int id) { if (!Access.HasAccess(75)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Shipping model = new Shipping(); model = model.GetById(id); model.Delete(model); return(RedirectToAction("Index")); }
public ActionResult CreateAjax(string name) { if (!Access.HasAccess(72)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Shipping theShipping = new Shipping(); theShipping.Name = name; theShipping.Save(theShipping); return(View(theShipping)); }
// // GET: /Store/ public ActionResult Index() { if (!Access.HasAccess(66)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Store theStore = new Store(); List <Store> theListStore = new List <Store>(); theListStore = (List <Store>)theStore.GetAll(); return(View(theListStore)); }
// // GET: /Devmodel/ public ActionResult Index() { if (!Access.HasAccess(51)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } List <Devmodel> theListDevmodel = new List <Devmodel>(); Devmodel theDevmodel = new Devmodel(); theListDevmodel = (List <Devmodel>)theDevmodel.GetAll(); return(View(theListDevmodel)); }
public ActionResult ResetPassword(ResetPasswordModel model) { if (ModelState.IsValid) { using (DBEntities db = new DBEntities()) { var playerDashboard = db.PlayerDashboard.FirstOrDefault(u => u.PlayerID == model.UserID); if (playerDashboard != null) { playerDashboard.PasswordResetCode = null; playerDashboard.ResetCodeExpiry = null; playerDashboard.DashboardPassword = SecurityUtils.EncryptText(model.ConfirmPassword); db.SaveChanges(); System.Web.Routing.RouteValueDictionary rt = new System.Web.Routing.RouteValueDictionary(); rt.Add("id", playerDashboard.DashboardURL); return(RedirectToAction("ResetPasswordSuccess", rt)); } else { ModelState.AddModelError("", "Password Reset Code is not valid."); } } } ViewBag.ModelIsLogin = true; ResetPasswordModel vmodel = new ResetPasswordModel() { UserID = model.UserID, NewPassword = model.NewPassword, ConfirmPassword = model.NewPassword, status = false, Reason = "Password Reset Code is not valid", AlertType = "danger" }; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { vmodel.Reason = error.ErrorMessage; } } return(View(vmodel)); }
public ActionResult Edit(int id, FormCollection collection) { if (!Access.HasAccess(43)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } try { // TODO: Add update logic here Area model = new Area(); model = model.GetById(id); model.Name = collection["Name"]; if (collection["User.ID"] != null) { model.User = (new User()).GetById(Convert.ToInt32(collection["User.ID"])); } if (collection["Store.ID"] != "") { model.Store = (new Store()).GetById(Convert.ToInt32(collection["Store.ID"])); } string IDs = collection["HouseSelections"]; if (IDs != null) { model.Houses.Clear(); model.Update(model); foreach (string item in IDs.Split(',')) { model.Houses.Add((new House()).GetById(Convert.ToInt32(item))); } } model.Update(model); return(RedirectToAction("Edit", new { id = model.Id })); } catch (Exception ex) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", ex.Message); return(RedirectToAction("Error", "Home", route)); } }
// // GET: /User/ public ActionResult Index() { if (!Access.HasAccess(1)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } List <User> theListUser = new List <User>(); User theUser = new User(); theListUser = (List <User>)theUser.GetAll(); return(View(theListUser)); }
// // GET: /Shipping/ public ActionResult Index() { if (!Access.HasAccess(71)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Shipping model = new Shipping(); List <Shipping> theListModel = new List <Shipping>(); theListModel = (List <Shipping>)model.GetAll("", "ID DESC"); return(View(theListModel)); }
// GET: /User/Create public ActionResult Create() { if (!AccessActions.IsAccess("User::Write")) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "��� �������!"); return(RedirectToAction("Error", "User", route)); } RoleModel role = new RoleModel(); BrancheModel branch = new BrancheModel(); //заполнение списка ролей ViewBag.Roles = role.FindAll(); //Заполнение списка филиалов ViewBag.Branches = branch.FindAll(); return(View()); }
public ActionResult Refund(int id) { if (!Access.HasAccess(50)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Device item = new Device(); item = item.GetById(id); item.StatusID = 1; item.IPAddr = ""; item.Host = ""; item.Update(item); return(View()); }
public ActionResult Delete(int id, FormCollection collection) { if (!Access.HasAccess(20)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } try { return(RedirectToAction("Index")); } catch { return(View()); } }
// // GET: /Shipping/Edit/5 public ActionResult Edit(int id) { if (!Access.HasAccess(73)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Shipping model = new Shipping(); model = model.GetById(id); ViewBag.Devmodels = (new Devmodel()).GetAll(); ViewBag.Matmodels = (new Matmodel()).GetAll(); return(View(model)); }
public ActionResult Distribute(int id) { if (!Access.HasAccess(73)) { System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); route.Add("err", "Нет доступа!"); return(RedirectToAction("Error", "Home", route)); } Shipping model = new Shipping(); model = model.GetById(id); ViewBag.Stores = (new Store()).GetAll("ID in (147, 84, 145, 81, 22, 121)"); ViewBag.Distributes = (new Shippingitemdistribute()).GetAll(); return(View(model)); }
public ViewNamespaceItem(Namespace<Kooboo.CMS.Sites.Models.View> ns) { base.Action = "index"; base.Controller = "view"; base.Area = "Sites"; base.Text = ns.Name; base.Visible = true; RouteValues = new System.Web.Routing.RouteValueDictionary(); RouteValues.Add("ns", ns.FullName); Initializer = new ViewNamespaceItemInitializer(); if (ns.ChildNamespaces != null) { this.Items = ns.ChildNamespaces.Select(it => new ViewNamespaceItem(it)).ToArray(); } }
public ViewNamespaceItem(Namespace <Kooboo.CMS.Sites.Models.View> ns) { base.Action = "index"; base.Controller = "view"; base.Area = "Sites"; base.Text = ns.Name; base.Visible = true; RouteValues = new System.Web.Routing.RouteValueDictionary(); RouteValues.Add("ns", ns.FullName); Initializer = new ViewNamespaceItemInitializer(); if (ns.ChildNamespaces != null) { this.Items = ns.ChildNamespaces.Select(it => new ViewNamespaceItem(it)).ToArray(); } }
/// <summary> /// Creates and Action link with a clickable image instead of text. /// </summary> /// <param name="helper"></param> /// <param name="controller">Controller</param> /// <param name="action">Action</param> /// <param name="parameters">Parameters</param> /// <param name="src">Image source</param> /// <param name="alt">Alternate text(Optional)</param> /// <returns>An HTML anchor tag with a nested image tag.</returns> /// public static MvcHtmlString OdrorirDelete(this HtmlHelper html, string linkText, string action, string controllerName, Guid id, object htmlAttributes) { var routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("id", id); //build the tag linkText = string.Format("{0} <span class='glyphicon glyphicon-trash'></span>", linkText); TagBuilder tagBuilder = new TagBuilder("a"); tagBuilder.InnerHtml = linkText; //Add Url UrlHelper urlHelper = new UrlHelper(html.ViewContext.RequestContext); var url = urlHelper.Action(action, routeValues);//(action+"/"+id, controllerName); string modalVal = "deleteModal"; tagBuilder.MergeAttribute("href", url); tagBuilder.MergeAttribute("odrorir-dialogs", modalVal); //put it all together return MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.Normal)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var orderIdValue = filterContext.Controller.ValueProvider.GetValue("orderGuid"); if (orderIdValue != null) { Guid orderId = new Guid(orderIdValue.AttemptedValue); Order order = this.QueryDispatcher.Dispatch<Order, GetOrderQuery>(new GetOrderQuery(orderId)); if (order == null) { filterContext.Result = new RedirectToRouteResult(Routes.Checkout.Index, new System.Web.Routing.RouteValueDictionary()); } else { Guid? memberGuid = this.GetMemberGuid(filterContext.HttpContext); if (memberGuid.HasValue && memberGuid.Value == order.MemberGuid) { if (order.Status == Orders.Enums.OrderStatus.Complete || order.Status == Orders.Enums.OrderStatus.AwaitingShipment) { var routeData = new System.Web.Routing.RouteValueDictionary(); routeData.Add("orderGuid", orderId); filterContext.Result = new RedirectToRouteResult(Routes.Checkout.Complete, routeData); } } else { filterContext.Result = new RedirectToRouteResult(Routes.Checkout.Index, new System.Web.Routing.RouteValueDictionary()); } } } else { filterContext.Result = new RedirectToRouteResult(Routes.Checkout.Index, new System.Web.Routing.RouteValueDictionary()); } }
public ActionResult Index(string serviceOfferingIdName, string button) { ControllerUtilities.CheckFlags(this); System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary(); if (button == "Submit") { if (serviceOfferingIdName == null) { return this.Index(); } try { var newDesktop = mgr.CreateDesktop(serviceOfferingIdName); // For CPBM plugin return a simple view with VM Id visible if (ViewBag.NoLinks != null) { return View("CreateComplete", newDesktop); } route.Add("newId", newDesktop.Id); } catch (System.Exception ex) { CtxTrace.TraceError(ex); ViewBag.ErrorMessage = ex.Message; return View("Error"); } } return RedirectToAction("Index", "Manage", route); }
public ActionResult Create([Bind(Include = "TicketId,DisplayName,UserId,ParentCommentId,Level,Body")] TicketComment comment, int? id, int? page, string anchor) { if (ModelState.IsValid) { comment.SetCreated(); comment.TicketId = (int)id; if (comment.DisplayName == "") comment.DisplayName = "(no name)"; db.TicketComments.Add(comment); db.SaveChanges(); TicketNotification.Notify(db, comment.TicketId, comment.Created, TicketNotification.EType.CommentCreated); // @Html.ActionLink("Details", "Details", "Posts", null, null, //anchor, new { id = ViewBag.id, page = ViewBag.page }, null) var route = new System.Web.Routing.RouteValueDictionary(); route.Add("id", id); route.Add("page", page); route.Add("anchor", "#"+anchor); // The next line keeps failing, work on it later // var url = UrlHelper.GenerateUrl("", "Details", "Posts","http","",anchor, // route, null,Url.RequestContext, false); // return new RedirectResult(url); return RedirectToAction("Details", "Tickets", route); } // Do this in every GET action... ViewBag.UserModel = ProjectsHelper.LoadUserModel(); return View(comment); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { var referrer = Request.UrlReferrer; if (Request.RawUrl.ToLower().Contains("partial") && referrer != null) { if (referrer.ToString().ToLower().Contains("login")) { filterContext.Result = RedirectToAction("Index", "Home"); base.OnActionExecuting(filterContext); return; } } else if (Request.RawUrl.ToLower().Contains("partial") && referrer == null) { filterContext.Result = RedirectToAction("Index", "Home"); base.OnActionExecuting(filterContext); return; } var LanguageData = PageLanguageHelper.GetLanguageContent("User", "Base/OnActionExecuting"); //Check authentification and user role var currentUser = SessionManager.GetUserSession(); //new check if end user and get user created User currentUserCreated = null; if (currentUser != null && currentUser.IsEndUser()) { var currentCustomer = Upsilab.Business.Utility.SessionManager.GetCustomerProspectSession(); currentUserCreated = currentCustomer.User1; } //end new Authentication authentification = Authentication.Parse(filterContext.ActionDescriptor.GetCustomAttributes(typeof(Authentication), false).FirstOrDefault()); if (authentification != null) { if (currentUser != null) { //TODO : checking user role using Feature object from database if (!authentification.HasAccess(currentUser, currentUserCreated)) { UserBL.Logout(); //Logout ? trying to access denied url, then logout ? filterContext.Result = RedirectToAction("ForceLogin", "User", new { isAjax = authentification.IsAjax }); return; } } else { string tempDataKey = Upsilab.Web.ExtranetUser.Controllers.UserController.LoginPageParameters.ReturnUrl; if (!TempData.ContainsKey(tempDataKey)) { TempData.Add(tempDataKey, Request.RawUrl); } if (Request.QueryString.Keys.Count > 0) { var redirect = new System.Web.Routing.RouteValueDictionary(); foreach (String key in Request.QueryString.Keys) { if (!redirect.ContainsKey(key)) { redirect.Add(key, Request.QueryString[key]); } } filterContext.Result = RedirectToAction("Login", "User", redirect); return; } filterContext.Result = RedirectToAction("ForceLogin", "User", new { isAjax = authentification.IsAjax }); return; } } //Set default language if (SessionManager.GetCurrentLanguage() == null) { SessionManager.SetCurrentLanguage(LanguageTypeBL.GetLanguageTypeByLanguageName(LanguageTypeBL.LanguageTypes.French)); } //Set application name if (currentUser != null) { string currentApplication = SessionManager.GetApplicationNameSession(); if (string.IsNullOrEmpty(currentApplication) && !currentUser.IsEndUser()) { currentApplication = Upsilab.Business.Souscription.SouscriptionBL.ReportLabApplication; //By default if (currentUser.IsSdgAdmin()) { currentApplication = Upsilab.Business.Souscription.SouscriptionBL.SignatureApplication; } else if (!Request.RawUrl.ToLower().Contains("/agreg") && (currentUser.HasReportLicense() || currentUser.HasLABLicense())) { currentApplication = Upsilab.Business.Souscription.SouscriptionBL.ReportLabApplication; } else if (Request.RawUrl.ToLower().Contains("/agreg") && currentUser.HasAggregatorLicense()) { currentApplication = Upsilab.Business.Souscription.SouscriptionBL.AgregateurApplication; } else if (currentUser.HasReportLicense() || currentUser.HasLABLicense()) { currentApplication = Upsilab.Business.Souscription.SouscriptionBL.ReportLabApplication; } else if (currentUser.HasAggregatorLicense()) { currentApplication = Upsilab.Business.Souscription.SouscriptionBL.AgregateurApplication; } SessionManager.SetApplicationNameSession(currentApplication); } } //4993 : Check IP address. Send mail to [email protected] if it's an competitor IP Upsilab.Business.Utility.SecurityHelper.CheckcompetitorIP(); base.OnActionExecuting(filterContext); }
public virtual void Login(string userName, string password) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("password", password); this.HttpClientPost("Login", userName, routeValues); }
public virtual System.Threading.Tasks.Task PostWithoutReturnValueAndWithoutFromBodyAttributeAsync(CoreWebApiClient.TestControllers.TestDto dto, string value) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("value", value); return this.HttpClientPostAsync("PostWithoutReturnValueAndWithoutFromBodyAttribute", dto, routeValues); }
public ActionResult Edit([Bind(Include = "Body,DisplayName,UpdateReason")] Comment comment, int? id, string anchor, int page, int? cid = null) { if (cid == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var route = new System.Web.Routing.RouteValueDictionary(); route.Add("id", id); route.Add("page", page); route.Add("anchor", "#" + anchor); if (ModelState.IsValid) { Comment orig = db.Comments.Find(cid); orig.Body = comment.Body; orig.DisplayName = comment.DisplayName; orig.UpdateReason = comment.UpdateReason; orig.Updated = DateTime.UtcNow; db.Entry(orig).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Details", "Posts", route); } return RedirectToAction("Details", "Posts", route); }
public ActionResult EditPhoto([Bind(Include = "Name,Description")] PhotoFile editfile, int? id) { string htmlattr = "FileUpload"; SaveObject Edit = new SaveObject(); if (!Regex.IsMatch(id.ToString(), Variables.RegexForNumbers)) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } if (Request.Files[htmlattr].ContentLength > 0) { Edit = PhotoHelper.EditPhoto((int)id, editfile, Request, Server, "Product", htmlattr); } else { PhotoFile file = db.Photos.Find(id); if (file == null) { return HttpNotFound(); } file.Description = editfile.Description; file.Name = editfile.Name; try { db.Photos.AddOrUpdate(file); db.SaveChanges(); Edit.isValid = true; } catch (Exception) { Edit.Error.Add("Something happened!"); Edit.isValid = false; } } if (Edit.isValid) { string path = ""; PhotoEdit check = PhotoEdit.def; if (Session["EditUrl"] != null) { check = (PhotoEdit)Enum.Parse(typeof(PhotoEdit), Session["EditUrl"].ToString()); Session.Remove("EditUrl"); } int EditId = 0; if(Session["EditID"] != null) { EditId = Regex.IsMatch(Session["EditID"].ToString(), Variables.RegexForNumbers) ? Int32.Parse(Session["EditID"].ToString()) : -1; Session.Remove("EditID"); if(EditId == -1) { Edit.Error.Add("Edit ID Problem or Something!"); ViewBag.Edit = Edit; return View(); } } string prod = null; dynamic model = null; switch (check) { case PhotoEdit.Create: ViewBag.FileName = db.Photos.Find(id); ViewBag.ProdCategories = new SelectList(db.ProdCategories, "CategoryId", "Name"); path = "Create"; break; case PhotoEdit.EditProduct: TempData["FileName"] = db.Photos.Find(id); // model = db.Products.Find(); prod = "Products"; path = "Edit"; break; case PhotoEdit.Edit: model = db.Photos.Find(id); path = "EditPhoto"; break; default: return RedirectToAction("Index"); } if(Session["FromEditProduct"] !=null) { bool ep = bool.Parse(Session["FromEditProduct"].ToString()); Session.Remove("FromEditProduct"); if(ep) { path = "Edit"; prod = "Products"; TempData["FileName"] = db.Photos.Find(id); } } System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("id", EditId); return RedirectToAction(path, prod, routeValues); } ViewBag.Edit = Edit; return View(); }
public ActionResult Sync(string id) { ApplicationDbContext context = new ApplicationDbContext(); //var container = context.CloudStorageContainers.Find(id); //var account = context.CloudStorageAccounts.Find(id); var cid = Guid.Parse(id); var account = context.CloudStorageAccounts.SingleOrDefault(c => c.PublicKey == cid); System.Web.Routing.RouteValueDictionary dict = new System.Web.Routing.RouteValueDictionary(); dict.Add("id", id); var containers = CloudStorageMananger.ImportContainers(account.AccountName, account.AccountKey); // .GetContainers(account.AccountName, account.AccountKey); foreach (var container in containers) { //container.CloudStorageAccountId = account.CloudStorageContainers.Add(container); } context.SaveChanges(); return RedirectToAction("Detail", dict); // , new { Id = id }); }
public virtual System.Threading.Tasks.Task<Eshop.Dtos.ProductDto> GetProductAsync(int productId) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("productId", productId); return this.HttpClientGetAsync<Eshop.Dtos.ProductDto>("GetProduct", routeValues); }
public virtual Eshop.Dtos.ProductDto GetProduct(int productId) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("productId", productId); return this.HttpClientGet<Eshop.Dtos.ProductDto>("GetProduct", routeValues); }
public virtual System.Threading.Tasks.Task<Eshop.Dtos.ProductSummaryDto[]> SearchProductsAsync(string searchedText) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("searchedText", searchedText); return this.HttpClientGetAsync<Eshop.Dtos.ProductSummaryDto[]>("SearchProducts", routeValues); }
public virtual Eshop.Dtos.ProductSummaryDto[] SearchProducts(string searchedText) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("searchedText", searchedText); return this.HttpClientGet<Eshop.Dtos.ProductSummaryDto[]>("SearchProducts", routeValues); }
public ActionResult Edit([Bind(Include = "Body,DisplayName,UpdateReason")] TicketComment comment, int? id, string anchor, int page, int? cid = null) { // Do this in every GET action... ViewBag.UserModel = ProjectsHelper.LoadUserModel(); if (cid == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var route = new System.Web.Routing.RouteValueDictionary(); route.Add("id", id); route.Add("page", page); route.Add("anchor", "#" + anchor); if (ModelState.IsValid) { TicketComment orig = db.TicketComments.Find(cid); orig.Body = comment.Body; orig.Updated = DateTime.UtcNow; db.Entry(orig).State = EntityState.Modified; db.SaveChanges(); TicketNotification.Notify(db, orig.TicketId, orig.Updated.Value, TicketNotification.EType.CommentModified); return RedirectToAction("Details", "Posts", route); } return RedirectToAction("Details", "Posts", route); }
public ActionResult DeleteConfirmed(int? id, string anchor, int page, int? cid = null) { // Want to delete the comment (cid is its id, NOT id!) Comment comment = db.Comments.Find(cid); comment.Deleted = true; //db.Comments.Remove(comment); db.SaveChanges(); var route = new System.Web.Routing.RouteValueDictionary(); route.Add("id", id); route.Add("page", page); route.Add("anchor", "#" + anchor); // The next line keeps failing, work on it later // var url = UrlHelper.GenerateUrl("", "Details", "Posts","http","",anchor, // route, null,Url.RequestContext, false); // return new RedirectResult(url); return RedirectToAction("Details", "Posts", route); }
public virtual System.Threading.Tasks.Task UpdateProductQuantityAsync(int productId, int quantity) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("quantity", quantity); return this.HttpClientPostAsync("UpdateProductQuantity", productId, routeValues); }
public ActionResult Create([Bind(Include = "Id,PostId,AuthorId,ParentCommentId,Level,Body,DisplayName,UpdateReason")] Comment comment, int? id, int? page, string anchor) { if (ModelState.IsValid) { comment.Created = DateTime.UtcNow; db.Comments.Add(comment); db.SaveChanges(); // @Html.ActionLink("Details", "Details", "Posts", null, null, //anchor, new { id = ViewBag.id, page = ViewBag.page }, null) var route = new System.Web.Routing.RouteValueDictionary(); route.Add("id", id); route.Add("page", page); route.Add("anchor", "#"+anchor); // The next line keeps failing, work on it later // var url = UrlHelper.GenerateUrl("", "Details", "Posts","http","",anchor, // route, null,Url.RequestContext, false); // return new RedirectResult(url); return RedirectToAction("Details", "Posts", route); } return View(comment); }
public virtual System.Threading.Tasks.Task<CoreWebApiClient.TestControllers.AnotherTestDto> PostWithReturnValueAsync(CoreWebApiClient.TestControllers.TestDto dto, string value) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("value", value); return this.HttpClientPostAsync<CoreWebApiClient.TestControllers.AnotherTestDto>("PostWithReturnValue", dto, routeValues); }
public ActionResult UploadPhoto([Bind(Include = "Name,Description")] PhotoFile file) { SaveObject obj; try { obj = PhotoHelper.SavePhoto(Request, Server, "Product", "FileUpload"); if (obj.isValid) { if (ModelState.IsValid) { file.FilePath = obj.FilePath; db.Photos.AddOrUpdate(file); db.SaveChanges(); Session.Add("FileID", file.PhotoId); } else { return View(file); } // ViewBag.ProdCategories = new SelectList(db.ProdCategories, "CategoryId", "Name"); string path = ""; PhotoEdit check = PhotoEdit.def; if (Session["EditUrl"] != null) { check = (PhotoEdit)Enum.Parse(typeof(PhotoEdit), Session["EditUrl"].ToString()); Session.Remove("EditUrl"); } int EditId = 0; if (Session["EditID"] != null) { EditId = Regex.IsMatch(Session["EditID"].ToString(), Variables.RegexForNumbers) ? Int32.Parse(Session["EditID"].ToString()) : -1; Session.Remove("EditID"); if (EditId == -1) { obj.Error.Add("Edit ID Problem or Something!"); ViewBag.Errors = obj; return View(); } } string prod = null; dynamic model = null; switch (check) { case PhotoEdit.Create: ViewBag.FileName = db.Photos.Find(file.PhotoId); ViewBag.ProdCategories = new SelectList(db.ProdCategories, "CategoryId", "Name"); path = "Create"; break; case PhotoEdit.EditProduct: TempData["FileName"] = db.Photos.Find(file.PhotoId); // model = db.Products.Find(); prod = "Products"; path = "Edit"; break; case PhotoEdit.Edit: model = db.Photos.Find(file.PhotoId); path = "EditPhoto"; break; default: return RedirectToAction("Index"); } System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("id",EditId); return RedirectToAction(path,prod,routeValues); // return RedirectToAction("Create"); } else { ViewBag.Errors = obj.Error; return View(); } } catch (HttpException) { obj = new SaveObject(); obj.isValid = false; obj.Error.Add("The size of the file must be below 6mb"); return View(); } }
public virtual void PostWithoutReturnValue(CoreWebApiClient.TestControllers.TestDto dto, string value) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("value", value); this.HttpClientPost("PostWithoutReturnValue", dto, routeValues); }
public virtual void UpdateProductQuantity(int productId, int quantity) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("quantity", quantity); this.HttpClientPost("UpdateProductQuantity", productId, routeValues); }
public virtual System.Threading.Tasks.Task LoginAsync(string userName, string password) { System.Web.Routing.RouteValueDictionary routeValues = new System.Web.Routing.RouteValueDictionary(); routeValues.Add("password", password); return this.HttpClientPostAsync("Login", userName, routeValues); }