public void Run() { ViewBagDynamic controller = new ViewBagDynamic(); ViewBag viewBag = new ViewBag(); viewBag.a = controller.a; viewBag.b = controller.b; viewBag.c = ViewBagDynamic.c; controller.ViewBag = viewBag; }
/// <summary> /// 获取所有成员名称 /// </summary> public List <string> GetKeys() { var arr = ViewBag.GetDynamicMemberNames(); if (arr != null) { return(arr.ToList()); } return(new List <string>()); }
public ActionResult OrderHistory() { ViewBag.Message = "Order History"; PizzaStoreDataServiceClient psDataClient = new PizzaStoreDataServiceClient(); List <OrderDAO> orderHistory = psDataClient.GetOrders().ToList(); ViewBag.Orders(orderHistory); return(View()); }
public override string Render(ViewBag data) { string ret = ""; foreach (var child in Children) { ret += child.Render(data); } return(ret); }
// GET: Product/Delete/5 public ActionResult Delete(int id) { if (_repository.ProductInUse(id, SessionManager.User.Id)) { ViewBag.ErrorMessage("Ce produit est dans votre frigo..."); return(View()); } _repository.Delete(id, SessionManager.User.Id); return(RedirectToAction("Index")); }
public void ImportInto(IChainImporter graph, ViewBag views) { // TODO -- will want this to suck in the configuration log business somehow Registry.Compile(); var childGraph = Registry.Configuration.BuildForImport(views); graph.Import(childGraph, b => { b.PrependToUrl(Prefix); b.Origin = Registry.Name; }); }
public IActionResult AddNewStudent(Student s) { try { ORM.Add(s); ORM.SaveChanges(); ViewBag.Message("Added!!!!!"); } catch (Exception ex) { ViewBag.Message("Not Added"); } return(RedirectToAction(nameof(StudentController.ViewAllStudents))); }
public ActionResult Login(Users model) { var user = db.Users.FirstOrDefault(x => x.UserName == model.UserName && x.Password == model.Password); if (user != null) { Session["user"] = user; return(RedirectToAction("Index", "Tasks")); } ViewBag.Error("Kullanıcı adı veya şifre yanlış!"); return(View()); }
public ActionResult GIRIS(Kullanıcılar Model) { var KULLANICI = db.Kullanıcılar.FirstOrDefault(x => x.KULLANICIADI == Model.KULLANICIADI && x.SIFRE == Model.SIFRE); if (KULLANICI != null) { Session["KULLANICIADI"] = KULLANICI; return(RedirectToAction("Index", "Home")); } ViewBag.Hata("kullanıcı Adı veya sıfre hatalı"); return(View()); }
public ActionResult Giris(Kullanici model) { var kullanici = te.Kullanici.FirstOrDefault(x => x.EPosta == model.EPosta && x.Sifre == model.Sifre); if (kullanici != null) { Session["EPosta"] = kullanici; return(RedirectToAction("Index", "Home")); } ViewBag.HATA("KULLANICI ADI YA DA ŞİFRE YANLIŞTIR.."); return(View()); }
public ActionResult Register(string identidad, string nombre, string Apellido, DateTime FechaNacimiento, string sexo, string Telefono, string correo, string password) { string UserName = nombre + Apellido; IEnumerable <object> listCategoria = null; string MensajeError = ""; try { listCategoria = db.UDP_Acce_tbUsuario_Insert(UserName, password); foreach (UDP_Acce_tbUsuario_Insert_Result Resultado in listCategoria) { MensajeError = Resultado.MensajeError; } if (MensajeError.StartsWith("-1")) { ViewBag.Error("Error al registrase, contacte al administrador."); return(View()); } else { tbCliente objCliente = new tbCliente(); objCliente.clte_Identidad = identidad; objCliente.clte_Nombre = nombre; objCliente.clte_Apellido = Apellido; objCliente.clte_FechaNacimiento = FechaNacimiento; objCliente.clte_Sexo = sexo; objCliente.clte_Telefono = Telefono; objCliente.clte_Correo = correo; objCliente.usu_Id = Convert.ToInt16(MensajeError); objCliente.clte_UsuarioCrea = 3; objCliente.clte_FechaCrea = DateTime.Now; db.tbCliente.Add(objCliente); db.SaveChanges(); Usuario_Rol usuarioRol = new Usuario_Rol(); usuarioRol.id_Rol = 2; usuarioRol.usu_Id = Convert.ToInt16(MensajeError); db.Usuario_Rol.Add(usuarioRol); db.SaveChanges(); } } catch (Exception Ex) { ViewBag.Error = "Se produjo un error al registrar, contacte al administrador"; return(View()); } ViewBag.Message = "Usuario registrado correctamente, inicie sesión"; return(RedirectToAction("Index")); }
public ActionResult Edit(Store store, Address address, string editcoverimage, string editprofileimage, int createStatus = 0) { // Check if there are 2 image files from Request if (Request.Files.AllKeys.Length != 2) { ViewBag.Message("Cover image and/or store avatar needed."); return(View("Error")); } Guid guid = new Guid(); var path = ""; List <Image> images = new List <Image>(); // Read each file from Request, create each corresponding Image object and added to Image list for (int i = 0; i < Request.Files.AllKeys.Length; i++) { HttpPostedFileBase hpf = Request.Files[i] as HttpPostedFileBase; if (hpf != null && hpf.ContentLength > 0) { guid = Guid.NewGuid(); path = Path.Combine(Server.MapPath("~/App_Data/Images"), guid.ToString()); hpf.SaveAs(path); images.Add(new Image { Path = guid.ToString() }); } } // Set images to Store object store.Address = address; if (ModelState.IsValid) { Store temp = db.Stores.Find(store.StoreId); temp.Slogan = store.Slogan; temp.StoreName = store.StoreName; temp.Description = store.Description; temp.ShipFee = store.ShipFee; temp.Address = address; if (editcoverimage == "true") { temp.CoverImage.Path = images.First().Path; } if (editprofileimage == "true") { temp.ProfileImage.Path = images.Last().Path; } db.SaveChanges(); return(View(temp)); } return(View(store)); }
public ActionResult EditUserInfo(UserInfo userInfo) { userInfo.ModifiedOn = DateTime.Now; if (userInfoService.EditEntity(userInfo)) { return(ViewBag.data("ok")); } else { return(ViewBag.data("no")); } }
// GET: Contact/Details/5 public ActionResult Details(int id) { DetailContactForm detailContactForm = _repository.Get(SessionManager.User.Id, id)?.ToDetail(); if (detailContactForm is null) { ViewBag.Error("Le contact n'existe pas"); return(RedirectToAction("Index")); } return(View(detailContactForm)); }
// GET: Contact/Delete/5 public ActionResult Delete(int id) { DetailContactForm detailContactForm = ServicesLocator.Instance.ContactService.Get(SessionManager.User.Id, id)?.ToDetail(); if (detailContactForm is null) { ViewBag.Error("Le contact n'existe pas"); return(RedirectToAction("Index")); } return(View(detailContactForm)); }
public ActionResult Add(AddOrderListView newentry) { List <Order> neworder = new List <Order>(); for (int i = 0; i < newentry.orderlist.Count; i++) { if (newentry.orderlist[i].PKProductId != 0 && newentry.orderlist[i].Amount != 0 && newentry.orderlist[i].OrderPlacingDateTime != null) { neworder.Add(new Order { CustomerId = 1, ProductId = newentry.orderlist[i].PKProductId, OrderPlacingDateTime = newentry.orderlist[i].OrderPlacingDateTime, OrderDateTime = System.DateTime.Now.Date, Amount = newentry.orderlist[i].Amount }); } } if (AgroExpressDBAccess.AddOrder(neworder)) { ViewBag.success("Order Successful"); } else { ViewBag.success("Sorry, Your order is not placed, Please try again"); } List <Product> prlist = AgroExpressDBAccess.GetAllEnabledProduct(); var ProductInf = AgroExpressDBAccess.GetAllEnabledProduct(); List <AddOrder> orders = new List <AddOrder>(); int len = ProductInf.Count; for (int i = 0; i < len; i++) { orders.Add(new AddOrder { productlist = ProductInf.Select(x => new SelectListItem { Value = x.PKProductId.ToString(), Text = x.ProductName }), OrderPlacingDateTime = System.DateTime.Now.Date, Amount = 0 }); } newentry.orderlist = orders; return(View(newentry)); }
public void ImportInto(BehaviorGraph graph, ViewBag views) { // TODO -- will want this to suck in the configuration log business somehow Registry.Compile(); var childGraph = Registry.Configuration.BuildForImport(graph); graph.As <IChainImporter>().Import(childGraph, b => { b.PrependToUrl(Prefix); b.Origin = Registry.Name; }); }
public ActionResult GetUserList() { var UserLIst = db.AspNetUsers.Where(p => p.IsProvider == false).ToList(); if (UserLIst != null) { return(View(UserLIst)); } else { return(ViewBag.Userlist("No User Yet Registered")); } }
public ActionResult Login(Mezunlar mezun) { var kullanici = dbdeneme.Mezunlar.FirstOrDefault(x => x.Okul_Numarasi == mezun.Okul_Numarasi && x.Sifre == mezun.Sifre); if (kullanici != null) { Session["Okul_Numarasi"] = kullanici;//içerde biri varsa tekrar giriş yaptırmasın. return(RedirectToAction("MezunIndex", "Mezunlar")); } ViewBag.Uyari("Kullanıcı Adı Veya Şifre Yanlış..."); return(View(mezun)); }
public void TestOneLevelIfEvalsToFalse() { var template = "<body> {% if a = 22 %} should NOT see this {% endif %} </body>"; var engine = new Engine(); var data = new ViewBag(); data["a"] = "1"; var ret = engine.Render(template, data); Assert.AreEqual("<body> </body>", ret); }
private void ViewInspection() { if (SelectedInspection == null) { return; } dynamic viewBag = new ViewBag(); viewBag.Inspection = SelectedInspection.Task; _router.GoTo(ControlType.TaskDetailsControl, viewBag); }
public void TestSimpleVariable() { var template = "<body>variable {{someVar}} </body>"; var engine = new Engine(); var data = new ViewBag(); data["someVar"] = "10"; var ret = engine.Render(template, data); Assert.AreEqual("<body>variable 10 </body>", ret); }
private void ToClient() { if (SelectedCustomer == null) { return; } dynamic viewBag = new ViewBag(); viewBag.Customer = SelectedCustomer; _router.GoTo(ControlType.ClientInfoControl, viewBag); }
public ActionResult Cacher(int id) { using (IDal dal = new Dal()) { int retour = dal.CacherActus(id); if (retour == -1) { ViewBag.ActionErreur("cacher une actualité"); } return(RedirectToAction("/")); } }
private void ExecuteInspection() { if (SelectedInspection == null) { return; } dynamic viewBag = new ViewBag(); viewBag.Inspection = SelectedInspection; _router.GoTo(ControlType.ExecuteInspectionControl, viewBag); }
private void OpenTask() { if (SelectedTask == null) { return; } dynamic viewBag = new ViewBag(); viewBag.Task = SelectedTask; _router.GoTo(ControlType.TaskDetailsControl, viewBag); }
public ActionResult GetproviderLIst() { var providerlist = db.AspNetUsers.Where(p => p.IsProvider == true).ToList(); if (providerlist != null) { return(View(providerlist)); } else { return(ViewBag.ProviderMessage("No Provider Yet Registered")); } }
private void ToTemplate() { if (SelectedChecklist == null) { return; } dynamic viewBag = new ViewBag(); viewBag.Template = SelectedChecklist.Checklist; _router.GoTo(ControlType.EditTemplateControl, viewBag); }
public void Setup() { _observer = new RecordingConfigurationObserver(); _action = ActionCall.For<ViewsForActionFilterTesterController>(x => x.AAction()); _fromFindsOne = new FakeViewToken(); _fromSecondFindsOne = new FakeViewToken(); _views = new ViewBag(new IViewToken[] { _fromFindsOne, _fromSecondFindsOne }); _filterThatFindsNone = createFilterThatReturns(new IViewToken[0]); _firstFilterThatFindsExactlyOne = createFilterThatReturns(_fromFindsOne); _secondFilterThatFindsExactlyOne = createFilterThatReturns(_fromSecondFindsOne); _filterThatFindsMultiple = createFilterThatReturns(_fromFindsOne, _fromSecondFindsOne); _viewAttacherConvention = new ViewAttacherConvention(); }
private void LinkInspector() { if (SelectedInspection == null) { return; } dynamic viewBag = new ViewBag(); viewBag.Inspection = SelectedInspection; _router.GoTo(ControlType.LinkInspectorControl, viewBag); }
public void Setup() { _observer = new RecordingConfigurationObserver(); _action = ActionCall.For <ViewsForActionFilterTesterController>(x => x.AAction()); _fromFindsOne = new FakeViewToken(); _fromSecondFindsOne = new FakeViewToken(); _views = new ViewBag(new IViewToken[] { _fromFindsOne, _fromSecondFindsOne }); _filterThatFindsNone = createFilterThatReturns(new IViewToken[0]); _firstFilterThatFindsExactlyOne = createFilterThatReturns(_fromFindsOne); _secondFilterThatFindsExactlyOne = createFilterThatReturns(_fromSecondFindsOne); _filterThatFindsMultiple = createFilterThatReturns(_fromFindsOne, _fromSecondFindsOne); _viewAttacherConvention = new ViewAttacherConvention(); }
public void Configure(ViewBag bag, BehaviorGraph graph) { bag .Views .Where(token => _viewTokenFilter(token)) .Each(token => { var chain = graph.AddChain(); var output = token.ToBehavioralNode(); chain.AddToEnd(output); _configureChain(chain); }); }
public void filter_just_returns_the_same() { var views = new IViewToken[]{ MockRepository.GenerateMock<IViewToken>(), MockRepository.GenerateMock<IViewToken>(), MockRepository.GenerateMock<IViewToken>(), MockRepository.GenerateMock<IViewToken>(), MockRepository.GenerateMock<IViewToken>(), MockRepository.GenerateMock<IViewToken>() }; var original = new ViewBag(views); new DefaultProfile().Filter(original).ShouldBeTheSameAs(original); }
public IEnumerable<IViewToken> Apply(ActionCall call, ViewBag views) { var handlerType = typeof(GetHandler<,>); var inputType = typeof(Edit<>); String handlerPrefix = handlerType.Name.Substring(0, handlerType.Name.IndexOf("`")); String inputPrefix = inputType.Name.Substring(0, inputType.Name.IndexOf("`")); if (call.HandlerType.Name.StartsWith(handlerPrefix) && call.Method.GetParameters()[0].ParameterType.Name.StartsWith(inputPrefix)) { var viewModelType = call.HandlerType.GetGenericArguments()[0]; return views.ViewsFor(viewModelType) .Where(view => view.Name == "Edit"); } return Enumerable.Empty<IViewToken>(); }
public IEnumerable<IViewToken> Apply(ActionCall call, ViewBag views) { if(call.OutputType() == typeof(FubuContinuation) || !_policyResolver.HasMatchFor(call)) { return new IViewToken[0]; } var viewName = _policyResolver.ResolveViewName(call); var viewLocatorName = _policyResolver.ResolveViewLocator(call); var allViewTokens = views .Views .Where(view => view.GetType().CanBeCastTo<SparkViewToken>()) .Cast<SparkViewToken>(); SparkViewDescriptor matchedDescriptor = null; foreach(var token in allViewTokens) { var view = viewName.RemoveSuffix(".spark"); var templatePath = !string.IsNullOrEmpty(viewLocatorName) ? "{0}{1}{2}".ToFormat(viewLocatorName, Path.DirectorySeparatorChar, view) : view; var descriptor = token .Descriptors .FirstOrDefault(d => d.Templates.Any(template => template.RemoveSuffix(".spark").ToLower().Equals(templatePath.ToLower()))); if(descriptor != null) { matchedDescriptor = descriptor; break; } } if(matchedDescriptor == null) { return new IViewToken[0]; } _visitorRegistry .VisitorsFor(call) .Each(visitor => visitor.Visit(matchedDescriptor, call)); return new IViewToken[] {new SparkViewToken(call, matchedDescriptor, viewLocatorName, viewName)}; }
public void Apply_should_NOT_return_get_view_token_for_GetHandler_action_with_Get_input_type_and_NO_view_named_View() { var filter = new ActionIsEditForViewModelType(); var handlerType = typeof(GetHandler<StubViewModel, StubEntity>); var call = new ActionCall( handlerType, handlerType.GetMethod("Retrieve", new[] { typeof(Edit<StubViewModel>) }) ); var views = new ViewBag(new[] { new StubViewToken { Name = "Foobar", ViewModelType = typeof(StubViewModel) } }); IEnumerable<IViewToken> results = filter.Apply(call, views); Assert.AreEqual(0, results.Count()); }
public void Configure(ViewBag bag, BehaviorGraph graph) { Executed = true; }
public void SetUp() { token = new FakeViewToken { Name = "A", Folder = GetType().Namespace, ViewType = typeof(FakeViewToken), ViewModelType = typeof (ViewModel1) }; var views = new List<IViewToken> { token }; bag = new ViewBag(views); filter = new ActionInSameFolderAsViewReturnsViewModelType(); }
public void SetUp() { token = new FakeViewToken { ViewName = "AAction", Namespace = GetType().Namespace, ViewModel = typeof (ViewModel1) }; var views = new List<IViewToken> { token }; bag = new ViewBag(views); filter = new ActionWithSameNameAndFolderAsViewReturnsViewModelType(); }
public IEnumerable<IViewToken> Apply(ActionCall call, ViewBag views) { Invocations++; return Enumerable.Empty<IViewToken>(); }
public ActionResult EditDetail(int OrderID, int id, OrderDetail od) { try { od = data.OrderDetails.Single(n => n.BookID == id && n.OrderID == OrderID); var number = od.Number; var o = data.Orders.Single(C => C.ID == od.OrderID); if (od == null) { return(RedirectToAction("Er404", "loi/")); } else { if (ModelState.IsValid) { if (od.Number <= 0) { ViewBag.Error("Số lượng không được bé hơn hoặc bằng không"); return(View()); } if (o.ModifiedBy != null) { o.ModifiedBy = Session["UserName"].ToString(); } if (o.ModifiedDate == null || o.ModifiedDate != null) { o.ModifiedDate = DateTime.Now; } } UpdateModel(od); data.SaveChanges(); //gửi mail vào sau khi thay đổi thành công dữ liệu string content = System.IO.File.ReadAllText(Server.MapPath("~/Areas/Admin/Content/template/update_od.html")); content = content.Replace("{{UserName}}", o.User.Name); content = content.Replace("{{OrderID}}", od.OrderID.ToString()); content = content.Replace("{{Book}}", od.Book.Name); if (od.Number > number || od.Number <= number) { content = content.Replace("{{change}}", "số lượng thành" + od.Number.ToString() + " thành công"); } var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString(); new MailHelper().SendMail(o.User.Email, "Thay đổi đơn hàng thành công", content); new MailHelper().SendMail(toEmail, "Thay đổi đơn hàng thành công", content); //gửi mail vào sau khi thay đổi thành công dữ liệu end } return(RedirectToAction("Edit", new { id = OrderID })); } catch { return(RedirectToAction("Er404", "loi/")); } }