public static string GetLayoutHtml(CommonViewModel model, string page, IEnumerable<string> stylesheets, IEnumerable<string> scripts) { if (model == null) throw new ArgumentNullException("model"); if (page == null) throw new ArgumentNullException("page"); if (stylesheets == null) throw new ArgumentNullException("stylesheets"); if (scripts == null) throw new ArgumentNullException("scripts"); var applicationPath = new Uri(model.SiteUrl).AbsolutePath; if (applicationPath.EndsWith("/")) applicationPath = applicationPath.Substring(0, applicationPath.Length - 1); var pageUrl = "assets/app." + page + ".html"; var json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }); var additionalStylesheets = BuildTags("<link href='{0}' rel='stylesheet'>", applicationPath, stylesheets); var additionalScripts = BuildTags("<script src='{0}'></script>", applicationPath, scripts); return LoadResourceString("Thinktecture.IdentityServer.Core.Views.Embedded.Assets.app.layout.html", new { siteName = model.SiteName, applicationPath, pageUrl, model = json, stylesheets = additionalStylesheets, scripts = additionalScripts }); }
public async Task<IViewComponentResult> InvokeAsync() { var model = new CommonViewModel<LastThreadsViewModel>(); model.DataViewModel = threads.GetLastThreads(lastThreadsCount).To<LastThreadsViewModel>().ToList(); if (Common.CurrentUser != null) { model.CurrentUser = Common.CurrentUser.To<UserViewModel>().FirstOrDefault(); } return View("_LastThreads", model); }
public async Task<IViewComponentResult> InvokeAsync() { var model = new CommonViewModel<CategoryViewModel>(); model.DataViewModel = categories.All().To<CategoryViewModel>().ToList(); if (Common.CurrentUser != null) { model.CurrentUser = Common.CurrentUser.To<UserViewModel>().FirstOrDefault(); } return View("_Categories", model); }
protected virtual Task<System.IO.Stream> Render(CommonViewModel model, string page) { string html; if (config != null) { html = AssetManager.GetLayoutHtml(model, page, config.Stylesheets, config.Scripts); } else { html = AssetManager.GetLayoutHtml(model, page); } return Task.FromResult(StringToStream(html)); }
public CommonViewModel GetProjects(int skip, int count) { var model = new CommonViewModel { Directions = _directionsDao.Load(), Projects = _projectsDao.Load(skip, count), News = new List<News.News>() }; if (model.Projects == null) return model; foreach (var news in model.Projects.Select(projects => _newsDao.LoadForProject(projects.Id))) { model.News.InsertRange(model.News.Count, news); } return model; }
public ActionResult SearchPalletNo(CommonViewModel model, GridSettings gridSettings) { try { ResponseResult <GridResponse <CommonSearchItem> > result; result = _commonSearchDomain.GetPalletNoWithStockFlag(model.KeyWord, gridSettings); if (!result.IsSuccess) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(Json(result.Data, JsonRequestBehavior.AllowGet)); } catch (Exception exception) { Debug.WriteLine(exception.Message); throw; } }
protected virtual Task <System.IO.Stream> Render(CommonViewModel model, string page, string clientName = null) { var json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }); string html = LoadHtml(page); html = Replace(html, new { siteName = AntiXssEncoder.HtmlEncode(model.SiteName, true), model = AntiXssEncoder.HtmlEncode(json, true), //siteName = Microsoft.Security.Application.Encoder.HtmlEncode(model.SiteName), //model = Microsoft.Security.Application.Encoder.HtmlEncode(json), clientName = clientName }); return(Task.FromResult(StringToStream(html))); }
public async Task <ActionResult> StoreBankCard(CommonViewModel model) { CommonViewModel Resultmodel = new CommonViewModel(); if (ModelState.IsValid) { // Inserting. await StoreData(model.CreditCardViewM); // Get Result // Initialization. // Get Result Resultmodel.CreditCardViewM = new CreditCards(); Resultmodel.CreditCardsList = await LoadData(); } // If we got this far, something failed, redisplay form return(View("StoreViewCredtCards", Resultmodel)); }
public async Task <IActionResult> PostComment(CommonViewModel vm) { if (ModelState.IsValid) { var user = await OnGetSesstion(); UserQAComment userQAComment = new UserQAComment(); userQAComment.Description = vm.QACommentsViewModel.Description; userQAComment.UserId = user; userQAComment.UserQACommentID = vm.QACommentsViewModel.UserQACommentID; userQAComment.UserQuestionId = vm.QACommentsViewModel.UserQuestionId; userQAComment.UserQAnswerId = vm.QACommentsViewModel.UserQAnswerId; userQAComment.Visibility = false; userQAComment.IsAnswer = false; _context.UserQAComment.Add(userQAComment); _context.SaveChanges(); return(RedirectToAction($"QuestionDetail", new { id = vm.QACommentsViewModel.UserQuestionId })); } return(NotFound()); }
public async Task <IActionResult> Upload(IFormFile file, CommonViewModel model) { var product = _appDbContext.Products.FirstOrDefault(p => p.ProductId == model.product.ProductId); var path = "/img/" + file.FileName; using (var fileStream = new FileStream(webHostEnvironment.WebRootPath + path, FileMode.Create)) { await file.CopyToAsync(fileStream); } var baseUrl = Request.GetTypedHeaders().Referer.ToString(); _appDbContext.Entry(product).State = EntityState.Modified; _appDbContext.Entry(product).CurrentValues.SetValues(product); _appDbContext.Entry(product).Property("ImageUrl").IsModified = true; product.ImageUrl = path; await _appDbContext.SaveChangesAsync(); return(Redirect(baseUrl)); }
public async Task <IActionResult> FullHistory() { if (_accessor.HttpContext.Session.GetString("role") == "user") { return(RedirectToAction("NoAccess", "Home")); } CommonViewModel model = new CommonViewModel() { tickets = await _ticketProcessor.LoadTickets(), ticketTypes = await _ticketProcessor.LoadTypes(), jurisdictions = await _jurisdictionProcessor.LoadJurisdictions() }; if (model.tickets == null) { return(RedirectToAction("Login", "Login")); } return(View(model)); }
/// <summary> /// Normal load html for flat html files /// </summary> /// <param name="name"></param> /// <returns></returns> private string LoadHtml(string name, CommonViewModel model, string clientName = null) { var json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }); //Hardcoded for now var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"CustomView"); file = Path.Combine(file, name + ".html"); var html = File.ReadAllText(file); html = Replace(html, new { siteName = SoftwareKobo.Net.WebUtility.HtmlEncode(model.SiteName), model = SoftwareKobo.Net.WebUtility.HtmlEncode(json), clientName = clientName }); return(html); }
public async Task <IActionResult> New() { var username = _accessor.HttpContext.Session.GetString("username"); CommonViewModel model = new CommonViewModel() { ticketTypes = await _ticketProcessor.LoadTypes(), jurisdictions = await _jurisdictionProcessor.LoadJurisdictions(), role = _accessor.HttpContext.Session.GetString("role"), ticket = new Ticket() { WhoSubmitted = username } }; if (model.ticketTypes == null) { return(RedirectToAction("Login", "Login")); } return(View(model)); }
public void Add_NewContent_RedirectToIndexView() { //Arrange var viewModel = new CommonViewModel(); viewModel.addContent = new ContentInsurance { Name = "Test Content", Value = 1000, CategoryId = 2 }; var policyService = new Mock <IInsurancePolicyService>(); policyService.Setup(c => c.AddContent(viewModel.addContent)); ContentInsurancesController controller = new ContentInsurancesController(policyService.Object); //Act IActionResult result = controller.Create(viewModel) as ActionResult; //Assert result .Should() .BeOfType <RedirectToActionResult>(); }
/// <summary> /// Loads the HTML for the authorize response page. /// </summary> /// <param name="model">The model.</param> /// <returns> /// Stream for the HTML /// </returns> public virtual async Task <Stream> AuthorizeResponse(AuthorizeResponseViewModel model) { var newModel = new CommonViewModel { SiteName = model.SiteName, SiteUrl = model.SiteUrl }; var scripts = new List <string>(); scripts.AddRange(config.Scripts ?? Enumerable.Empty <string>()); scripts.Add("~/assets/app.FormPostResponse.js"); var data = BuildModelDictionary(newModel, AuthorizeResponseView, config.Stylesheets, scripts); data.Add("responseUri", model.ResponseFormUri); data.Add("responseFields", model.ResponseFormFields); string html = await LoadHtmlTemplate(AuthorizeResponseView); html = FormatHtmlTemplate(html, data); return(html.ToStream()); }
//lấy tất cả thông tin đặt tour miền Nam theo mã booking public CommonViewModel GetThongTinBookingTourMienNam(string bookingCode) { var lsResult = from cthd in _db.CTHoadonNams join t in _db.Tours on cthd.TourID equals t.ID join hd in _db.Hoadons on cthd.HoadonID equals hd.ID join kh in _db.Khachhangs on hd.KhachHangID equals kh.ID where cthd.Hoadoncode == bookingCode select new { t.Tentour, t.Code, t.Diadiemkhoihanh, t.Ngaydi, /*t.Ngayve,*/ t.Diemden, cthd.Hotenkhachhang, cthd.Sdt, cthd.Email, cthd.Hoadoncode, cthd.Songuoidi, hd.Ngaylaphd, hd.Tongtien, hd.Ghichu, hd.Ptthanhtoan, kh.Diachi, hd.Tinhtrang, t.Thuocmien, t.Gianguoilon }; var common = new CommonViewModel(); foreach (var item in lsResult) { common.Tentour = item.Tentour; common.Code = item.Code; common.Diadiemkhoihanh = item.Diadiemkhoihanh; common.Diemden = item.Diemden; common.Ngaydi = item.Ngaydi; common.Gianguoilon = item.Gianguoilon; common.Ghichu = item.Ghichu; common.Hoadoncode = item.Hoadoncode; common.Ptthanhtoan = item.Ptthanhtoan; common.Tongtien = item.Tongtien; common.Ngaylaphd = item.Ngaylaphd; common.Hoten = item.Hotenkhachhang; common.Diadiemkhoihanh = item.Diadiemkhoihanh; common.Sdt = item.Sdt; common.Email = item.Email; common.Diachi = item.Diachi; common.Songuoidi = item.Songuoidi; common.Tinhtrang = item.Tinhtrang; common.Thuocmien = item.Thuocmien; } return(common); }
Dictionary <string, object> BuildModelDictionary(CommonViewModel model, string page, IEnumerable <string> stylesheets, IEnumerable <string> scripts) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (stylesheets == null) { throw new ArgumentNullException(nameof(stylesheets)); } if (scripts == null) { throw new ArgumentNullException(nameof(scripts)); } var applicationPath = new Uri(model.SiteUrl).AbsolutePath; if (applicationPath.EndsWith("/")) { applicationPath = applicationPath.Substring(0, applicationPath.Length - 1); } var json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, settings); var additionalStylesheets = BuildTags("<link href='{0}' rel='stylesheet'>", applicationPath, stylesheets); var additionalScripts = BuildTags("<script src='{0}'></script>", applicationPath, scripts); return(new Dictionary <string, object> { { "siteName", Microsoft.Security.Application.Encoder.HtmlEncode(model.SiteName) }, { "applicationPath", applicationPath }, { "model", Microsoft.Security.Application.Encoder.HtmlEncode(json) }, { "page", page }, { "stylesheets", additionalStylesheets }, { "scripts", additionalScripts } }); }
public ActionResult PostAd(CommonViewModel model, int Cid, int Subid) { HttpResponseMessage result = null; if (model.ModelName == "Vehicle") { model.Vehicle.File = SaveFileDetails(model.files, Cid, Subid); model.Vehicle.Cid = Cid; model.Vehicle.Subid = Subid; model.Vehicle.Email = User.Identity.Name; result = PastDataVehicle(model.Vehicle); } else if (model.ModelName == "Book") { result = PastDataBook(model.Vehicle); } if (result.IsSuccessStatusCode) { return(RedirectToAction("PostAd")); } return(View()); }
object BuildModel(CommonViewModel model, string page, ICollection <string> stylesheets, ICollection <string> scripts) { if (model == null) { throw new ArgumentNullException("model"); } if (stylesheets == null) { throw new ArgumentNullException("stylesheets"); } if (scripts == null) { throw new ArgumentNullException("scripts"); } var applicationPath = new Uri(model.SiteUrl).AbsolutePath; if (applicationPath.EndsWith("/")) { applicationPath = applicationPath.Substring(0, applicationPath.Length - 1); } var json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, settings); var additionalStylesheets = BuildTags("<link href='{0}' rel='stylesheet'>", applicationPath, stylesheets); var additionalScripts = BuildTags("<script src='{0}'></script>", applicationPath, scripts); return(new { siteName = Microsoft.Security.Application.Encoder.HtmlEncode(model.SiteName), applicationPath, model = Microsoft.Security.Application.Encoder.HtmlEncode(json), page, stylesheets = additionalStylesheets, scripts = additionalScripts }); }
/// <summary> /// Renders the specified page. /// </summary> /// <param name="model">The model.</param> /// <param name="page">The page.</param> /// <returns></returns> protected virtual Task <Stream> Render(CommonViewModel model, string page) { return(Render(model, page, config.Stylesheets, config.Scripts)); }
/// <summary> /// Builds the model. /// </summary> /// <param name="model">The model.</param> /// <param name="page">The page.</param> /// <param name="stylesheets">The stylesheets.</param> /// <param name="scripts">The scripts.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// model /// or /// stylesheets /// or /// scripts /// </exception> protected object BuildModel(CommonViewModel model, string page, IEnumerable <string> stylesheets, IEnumerable <string> scripts) { return(BuildModelDictionary(model, page, stylesheets, scripts)); }
public async Task Refresh() { await CommonViewModel.LoadCurrentlyShownElementsAsync(); }
public IActionResult MyPage() { CommonViewModel model = new CommonViewModel(friend, chatMessage, user, user.GetUserId(User)); return(View(model)); }
public IActionResult Index([FromServices] IGenericService <TeamMember> teamSvc, [FromServices] IGenericService <Customer> customerSvc, CommonViewModel model) { model.Team = teamSvc.GetAll(); model.Customers = customerSvc.GetAll(); if (ModelState.IsValid) { try { TesteEnvioEmail(model.Email.CustomerEmail, model.Email.Subject, model.Email.Message, model.Email.Name).GetAwaiter(); model.StatusModel = "true"; View("Index", model); } catch (Exception ex) { model.StatusModel = "error"; View("Index", model); } } else { model.StatusModel = "false"; } return(View("Index", model)); }
protected virtual Task <System.IO.Stream> Render(CommonViewModel model, string page) { string html = AssetManager.GetLayoutHtml(model, page, config.Stylesheets, config.Scripts); return(Task.FromResult(StringToStream(html))); }
public CommonPage() { InitializeComponent(); BindingContext = new CommonViewModel(); }
public ActionResult SearchByKeyWord(CommonViewModel model, GridSettings gridSettings) { ResponseResult <GridResponse <CommonSearchItem> > result; switch (model.ModelType) { case "modalContainerTypeSelect": result = _commonSearchDomain.GetContainerType(model.KeyWord, gridSettings); break; case "modalMaterialCodeSelect": result = _commonSearchDomain.GetMaterialCode(model.KeyWord, gridSettings); break; case "modalPreProductCodeSelect": result = _commonSearchDomain.GetPreproductCode(model.KeyWord, gridSettings); break; case "modalProductCodeSelect": result = _commonSearchDomain.GetProductCode(model.KeyWord, gridSettings); break; case "modalOutOfPlanProductCodeSelect": result = _commonSearchDomain.GetOutOfPlanProduct(model.KeyWord, gridSettings); break; case "modalSupplementMaterialCodeSelect": result = _commonSearchDomain.GetSupMatCode(model.KeyWord, gridSettings); break; case "modalEndUserCodeSelect": result = _commonSearchDomain.GetEndUserCode(model.KeyWord, gridSettings); break; case "modalShippingNoSelect": result = _commonSearchDomain.GetShippingNo(model.KeyWord, gridSettings); break; case "modalProductLotNoSelect": result = _commonSearchDomain.GetProductLotNo(model.KeyWord, gridSettings); break; case "modalPONOSelect": result = _commonSearchDomain.GetPONo("", model.KeyWord, gridSettings); break; case "modalPalletNoSelect": result = _commonSearchDomain.GetProductPalletNo(model.KeyWord, gridSettings); break; case "modalTabletingLineSelect": result = _commonSearchDomain.GetTabletingLine(model.KeyWord, gridSettings); break; case "modalShelfNoSelect": result = _commonSearchDomain.GetShelfNo(model.KeyWord, gridSettings); break; case "modalLabelPrintManagement": result = _commonSearchDomain.FindProductLabelList(model.KeyWord, gridSettings); break; default: result = _commonSearchDomain.GetSupplierCodes(model.KeyWord, gridSettings); break; } if (!result.IsSuccess) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(Json(result.Data, JsonRequestBehavior.AllowGet)); }
//public ActionResult LoadProductLabels() //{ // var model = new CommonViewModel(); // model.Grid = InitiateProductLabelsList(); // model.ModelType = "labelPrintManagement"; // model.ListLabel = "Product labels list"; // return PartialView("_PartialSelectView", model); //} public ActionResult LoadSelected(string modelId) { var model = new CommonViewModel(); switch (modelId) { case "modalSupplierCodeSelect": model.Grid = GenerateGridSupplier(); model.ListLabel = "List of Supplier"; break; case "modalContainerTypeSelect": model.Grid = GenerateGridContainer(); model.ListLabel = "List of Container Type"; break; case "modalMaterialCodeSelect": model.Grid = GenerateGridMaterial(); model.ListLabel = "List of Material"; break; case "modalPreProductCodeSelect": model.Grid = GenerateGridPreProduct(); model.ListLabel = "List of Pre-Product "; break; case "modalProductCodeSelect": model.Grid = GenerateGridProduct(); model.ListLabel = "List of Product"; break; case "modalSupplementMaterialCodeSelect": model.Grid = GenerateGridSupplementMaterial(); model.ListLabel = "List of Supplement Material"; break; case "modalEndUserCodeSelect": model.Grid = GenerateGridEndUser(); model.ListLabel = "List of End Users"; break; case "modalShippingNoSelect": model.Grid = GenerateGridShippingNo(); model.ListLabel = "List of Shipping No"; break; case "modalProductLotNoSelect": model.Grid = GenerateGridProductLotNo(); model.ListLabel = "List of Product Lot No."; break; case "modalPONOSelect": model.Grid = GenerateGridPONO(); model.ListLabel = "List of P.O NO"; break; case "modalPalletNoSelect": model.Grid = GenerateGridPalletNo(); model.ListLabel = "List of Pallet No"; break; case "modalTabletingLineSelect": model.Grid = GenerateGridTabletingLine(); model.ListLabel = "List of Tableting Line"; break; case "modalShelfNoSelect": model.Grid = GenerateGridShelfNo(); model.ListLabel = "List of Empty Shelf"; break; case "modalOutOfPlanProductCodeSelect": model.Grid = GenerateGridOutOfPlanProduct(); model.ListLabel = "List Of Out Of Plan Product"; break; case "modalLabelPrintManagement": model.Grid = GenerateProductLabelsList(); model.ListLabel = "List Product"; break; default: break; } model.ModelType = modelId; return(PartialView("_PartialSelectView", model)); }
public ViewCreatedEventArgs(View view, CommonViewModel ViewModel) { this.View = view; this.ViewModel = ViewModel; }
public MenuViewModel(CommonViewModel commonViewModel) { _commonViewModel = commonViewModel; }
public static string GetLayoutHtml(CommonViewModel model, string page) { return GetLayoutHtml(model, page, Enumerable.Empty<string>(), Enumerable.Empty<string>()); }
public ModelViewModel(CommonViewModel commonViewModel) { _commonViewModel = commonViewModel; Model3dViewModel.PropertyChanged += OnModelPropertyChanged; }
public ActionResult Index(CommonViewModel cm) { return(View(cm)); }
private async void OnSelectedTagsChanged(object sender, EventArgs args) { await CommonViewModel.LoadCurrentlyShownElements(SelectedTags.ToList()); }
public PropertyViewModel(CommonViewModel commonViewModel) { _commonViewModel = commonViewModel; }
public static string GetLayoutHtml(CommonViewModel model, string page) { return(GetLayoutHtml(model, page, Enumerable.Empty <string>(), Enumerable.Empty <string>())); }