public string this[string key] { get { if (!data.ContainsKey(key.ToLower())) { data.Add(key.ToLower(), ""); } return(data[key.ToLower()]); } set { data[key.ToLower()] = value; } }
public ActionResult Edit(int id) { ViewBag.ExComments = _commentService.GetAllComments(); var postViewModel = _postService.GetPost(id); ViewData.Add("PostComments", postViewModel.CommentsEnabled); if (!ViewData.ContainsKey("postId")) { ViewData.Add("postId", postViewModel.Id); } else { ViewData["postId"] = postViewModel.Id; } if (!ViewData.ContainsKey("PostComments")) { ViewData.Add("PostComments", postViewModel.CommentsEnabled); } else { ViewData["PostComments"] = postViewModel.CommentsEnabled; } return(View(_postService.GetPost(id))); }
private AuditReportBase GetReport(AuditReportType type) { string key = string.Join(type.GetType().FullName, "_", type.ToString()); AuditReportBase report = null; if (ViewData.ContainsKey(key)) { report = ViewData[key] as AuditReportBase; } if (report == null) { switch (type) { case AuditReportType.InitialDocumentationRequest: report = CPProfile.InitialDocumentationRequest; break; case AuditReportType.DraftAuditReport: report = CPProfile.DraftAuditReport; break; case AuditReportType.FinalAuditReport: report = CPProfile.FinalAuditReport; break; } if (report != null) { ViewData[key] = report; } } return(report); }
public async Task <IActionResult> Problemset(string prob, [FromServices] IProblemStore probs) { if (TooEarly && !ViewData.ContainsKey("IsJury")) { return(NotFound()); } var problem = Problems.Find(prob); if (problem == null) { return(NotFound()); } var viewFile = probs.GetFile(problem, "view.html"); var view = await viewFile.ReadAsync(); if (string.IsNullOrEmpty(view)) { return(NotFound()); } ViewData["Content"] = view; return(View("ProblemView")); }
public async Task <IActionResult> DeleteConfirmed(int id) { var dogeImage = await _context.Images.FindAsync(id); _context.Images.Remove(dogeImage); await _context.SaveChangesAsync(); var dogePost = _context.Posts.Any(p => p.DogeImage == dogeImage); Console.WriteLine(dogePost); string sort = ""; int index = 1; if (ViewData.ContainsKey("CurrentSort")) { sort = ViewData["CurrentSort"].ToString(); } if (ViewData.ContainsKey("PageIndex")) { index = int.Parse(ViewData["PageIndex"].ToString()); } return(RedirectToAction(nameof(Index), new { sortOrder = sort, pageNumber = index })); }
public void BeforeRender() { #region << Set BodyClass >> if (ToolbarMenu.Count > 0) { var bodyClass = ViewData.ContainsKey("BodyClass") ? ViewData["BodyClass"].ToString().ToLowerInvariant() : ""; if (!bodyClass.Contains("has-toolbar")) { ViewData["BodyClass"] = bodyClass + " has-toolbar "; } } if (SidebarMenu.Count > 0) { var bodyClass = ViewData.ContainsKey("BodyClass") ? ViewData["BodyClass"].ToString().ToLowerInvariant() : ""; var classAddon = ""; if (!bodyClass.Contains("sidebar-")) { if (CurrentUser != null && !String.IsNullOrWhiteSpace(CurrentUser.Preferences.SidebarSize)) { if (CurrentUser.Preferences.SidebarSize != "lg") { CurrentUser.Preferences.SidebarSize = "sm"; } classAddon = $" sidebar-{CurrentUser.Preferences.SidebarSize} "; } else { classAddon = " sidebar-sm "; } ViewData["BodyClass"] = bodyClass + classAddon; } } #endregion }
public async Task OnGetAsync(string returnUrl = null) { try { if (!string.IsNullOrEmpty(ErrorMessage)) { ModelState.AddModelError(string.Empty, ErrorMessage); } returnUrl ??= Url.Content("~/"); // Clear the existing external cookie to ensure a clean login process await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (!ViewData.ContainsKey("CompanyName")) { ViewData.Add("CompanyName", await _nodeContext.CompanyName); } ReturnUrl = returnUrl; } catch (Exception e) { _nodeContext.ErrorLog(e); throw; } }
protected async Task SetViewData() { if (!ViewData.ContainsKey("CompanyName")) { ViewData.Add("CompanyName", await NodeContext.CompanyName); } }
public ActionResult Checkout() { string message = ""; using (DBEntities de = new DBEntities()) { List <Order> ordersList = new List <Order>(); double totalOrderPrice = 0.0; var currentUserEmailIdentity = HttpContext.User.Identity.Name; var currentUser = de.Users.Where(a => a.EmailID == currentUserEmailIdentity).FirstOrDefault(); var ordersByCurrentUser = de.Orders.Where(a => a.UserID == currentUser.UserID); foreach (var order in ordersByCurrentUser) { ordersList.Add(order); if (!ViewData.ContainsKey("pizzaPicturePath" + order.OrderID)) { ViewData.Add("pizzaPicturePath" + order.OrderID, order.Pizza.PizzaPicturePath); } if (!ViewData.ContainsKey("pizzaName" + order.OrderID)) { ViewData.Add("pizzaName" + order.OrderID, order.Pizza.PizzaName); } if (!ViewData.ContainsKey("pizzaSize" + order.OrderID)) { ViewData.Add("pizzaSize" + order.OrderID, order.Pizza.PizzaSize); } if (!ViewData.ContainsKey("orderPrice" + order.OrderID)) { ViewData.Add("orderPrice" + order.OrderID, order.Pizza.PizzaPrice * order.PizzaAmount); // Order price = pizza price multiplied by pizza amount. } totalOrderPrice += order.Pizza.PizzaPrice * order.PizzaAmount; } if (!ViewData.ContainsKey("totalOrderPrice")) { ViewData.Add("totalOrderPrice", totalOrderPrice); } if (ordersByCurrentUser.Count() == 1) { message = "There is " + ordersByCurrentUser.Count().ToString() + " pizza in your cart!"; } else if (ordersByCurrentUser.Count() > 1) { message = "There are " + ordersByCurrentUser.Count().ToString() + " pizzas in your cart!"; } else { message = "Your cart is empty!"; } ViewBag.Message = message; ViewBag.Message2 = TempData["orderInfo"]; return(View(ordersList)); } }
public object ItemEditSave(PluginAddress pluginAddress, PluginEditInput pluginEditInput, bool isEditingCode) { if (isEditingCode && !string.IsNullOrEmpty(pluginEditInput.VirtualPath)) { pluginEditInput.VirtualPath.SaveFileText(pluginEditInput.Code, HttpContext); pluginEngine.ReloadPlugin(p => p.Tag == null && !(p.Tag is Plugin) && string.Compare(p.VirtualPath, pluginEditInput.VirtualPath, true) == 0, p => pluginEditInput.VirtualPath); return(EditNotInstalled(new PluginNotInstalledAddress(pluginEditInput.VirtualPath))); } ModelResult <Plugin> results = null; Plugin plugin = pluginService.GetPlugin(pluginAddress); if (isEditingCode && !string.IsNullOrEmpty(pluginEditInput.Code) && pluginEditInput.Code != plugin.GetFileText()) { results = pluginService.EditPlugin(pluginAddress, pluginEditInput, true); } else if (!isEditingCode) { results = pluginService.EditPlugin(pluginAddress, pluginEditInput, false); } if (results != null && !results.IsValid) { ViewData["ValidationState"] = results.ValidationState; } if (isEditingCode || ViewData.ContainsKey("ValidationState")) { return(ItemEdit(pluginAddress, pluginEditInput)); } return(Redirect(Url.Plugin(plugin))); }
// GET: PostModels/Details/5 public ActionResult Details(int?id) { ViewBag.ExComments = _commentService.GetAllComments().Where(comment => comment.PostId == id); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var postViewModel = _postService.GetPost(id.Value); if (postViewModel == null) { return(HttpNotFound()); } if (!ViewData.ContainsKey("postId")) { ViewData.Add("postId", postViewModel.Id); } else { ViewData["postId"] = postViewModel.Id; } if (!ViewData.ContainsKey("PostComments")) { ViewData.Add("PostComments", postViewModel.CommentsEnabled); } else { ViewData["PostComments"] = postViewModel.CommentsEnabled; } return(View(postViewModel)); }
/// <summary> /// JQuery Table update route /// </summary> /// <param name="sortVariable"></param> /// <param name="searchString"></param> /// <param name="culture"></param> /// <param name="page"></param> /// <returns></returns> public async Task <PartialViewResult> Table(string sortVariable, string searchString, string culture, int page = 0) { ViewData["CurrentSort"] = string.IsNullOrEmpty(sortVariable) ? "Date_desc" : sortVariable; ViewData["Page"] = page; culture = ViewData.ContainsKey("Language") ? ViewData["Language"].ToString() : culture; SetSearchString(ref searchString); SetCultureCookie(culture, page.ToString(), searchString, sortVariable, Response); SetLanguage(culture); if (searchString == "Find model / date / owner...") { searchString = "EquipType:Chromebook"; } else { searchString += "EquipType: Chromebook"; } return(PartialView(await((EquipmentRequestHandler)_service).IndexRequest <EquipmentViewModel>( new IndexRequestModel() { SortVariable = ViewData["CurrentSort"].ToString(), Page = page, SearchString = searchString, PageSize = _pageSize, Type = "Chromebook" }) )); }
public ActionResult CreateDimension(EditDimensionViewModel viewModel) { if (viewModel != null && viewModel.ProjectId != null && ModelState.IsValid) { bool hasMultipleRequests = ViewData.ContainsKey("MultipleRequests"); int dimensionId = -1; if (!hasMultipleRequests) { try { dimensionId = Repository.Create(viewModel.ToDomainModel()); } catch (EntityAlreadyExistsException ex) { ModelState.AddModelError("Name", ex.Message); return(RedirectToAction("EditDimension", new { viewModel.ProjectId, viewModel.DimensionId })); } GlobalHost.ConnectionManager.GetHubContext <MorphologicalChartHub>().Clients.All.refresh(); } if (dimensionId > 0 || hasMultipleRequests) { return(RedirectToAction("EditProject", "Project", new { viewModel.ProjectId })); } } return(View("Error")); }
public ActionResult StatProduct() { var prods = ProductService.GetAllProducts(); var items = ItemService.GetAll(); int count = 0; foreach (var i in items) { if (i.ProductId != null) { Product p = ProductService.GetProductById((int)i.ProductId); count++; if (ViewData.ContainsKey(p.Name)) { ViewData[p.Name] = 1 + (int)ViewData[p.Name]; } else { ViewData.Add(p.Name, 1); } } } ViewBag.count = count; // ViewData.Add(stats); // ViewBag.stats = stats; return(View()); }
public ActionResult DeleteDimension(int?dimensionId, int?projectId) { if (dimensionId == null || projectId == null || !ModelState.IsValid) { return(View("Error")); } if (!ViewData.ContainsKey("MultipleRequests")) { try { Repository.Delete(dimensionId.Value); } catch (EntityNotFoundException ex) { ModelState.AddModelError("Name", ex.Message); return(RedirectToAction("EditDimension", new { projectId, dimensionId })); } GlobalHost.ConnectionManager.GetHubContext <MorphologicalChartHub>().Clients.All.refresh(); } return(RedirectToAction("EditProject", "Project", new { ProjectId = projectId.Value })); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var pageViewModels = _pS.GetPage(id); if (pageViewModels == null) { return(HttpNotFound()); } ViewBag.ExComments = _commentService.GetAllComments().Where(m => m.PageId == id); var page = _pS.GetPage(id); if (!ViewData.ContainsKey("pageId")) { ViewData.Add("pageId", page.PageId); } else { ViewData["pageId"] = page.PageId; } if (!ViewData.ContainsKey("PageComments")) { ViewData.Add("PageComments", page.CommentsEnabled); } else { ViewData["PageComments"] = page.CommentsEnabled; } return(View(pageViewModels)); }
public async Task <IActionResult> Approve(int?id) { //id is Image id var post = (from p in _context.Posts where p.Id == (from im in _context.Images where im.Id == id select im).FirstOrDefault().Id select p).FirstOrDefault(); post.IsApproved = true; await _context.SaveChangesAsync(); //redirect to same page with only favorite posts displayed string sort = ""; int index = 1; if (ViewData.ContainsKey("CurrentSort")) { sort = ViewData["CurrentSort"].ToString(); } if (ViewData.ContainsKey("PageIndex")) { index = int.Parse(ViewData["PageIndex"].ToString()); } return(RedirectToAction(nameof(Index), new { sortOrder = sort, pageNumber = index })); }
public virtual JsonResult GetList() { GridData data = new GridData(Request.Form, tag => { var dropTag = tag as DropDownListDescriptor; if (dropTag != null && dropTag.SourceType == SourceType.ViewData && ViewData.ContainsKey(dropTag.SourceKey)) { Dictionary <string, string> options = new Dictionary <string, string>(); var list = (ViewData[dropTag.SourceKey] as SelectList); foreach (SelectListItem item in list) { if (!options.ContainsKey(item.Value)) { options.Add(item.Value, item.Text); } } return(options); } return(null); }); var filter = data.GetDataFilter <TEntity>(); var pagin = data.GetPagination(); return(Json(data.GetJsonDataForGrid(Service.Get(filter, pagin), pagin))); }
public async Task <IActionResult> ProblemView(string prob, [FromServices] ISubmissionStore submissions, [FromServices] IProblemStore problems) { if (TooEarly && !ViewData.ContainsKey("IsJury")) { return(NotFound()); } var problem = Problems.Find(prob); if (problem == null) { return(NotFound()); } ViewBag.CurrentProblem = problem; var fileInfo = problems.GetFile(problem, "view.html"); var view = await fileInfo.ReadAsync(); if (string.IsNullOrEmpty(view)) { return(NotFound()); } ViewData["Content"] = view; int pid = problem.ProblemId; int tid = Team?.TeamId ?? -1000; int cid = Contest.ContestId; var model = await submissions.ListWithJudgingAsync( s => s.ProblemId == pid && s.Author == tid && s.ContestId == cid); return(View(model)); }
public override Task ExecuteResultAsync(ActionContext context) { if (!ViewData.ContainsKey("HandleKey2")) { throw new InvalidOperationException(); } return(base.ExecuteResultAsync(context)); }
public IActionResult Submit() { if (TooEarly && !ViewData.ContainsKey("IsJury")) { return(Message("Submit", "Contest not started.", MessageType.Danger)); } return(Window(new TeamCodeSubmitModel())); }
public async Task <IActionResult> OnGetAsync() { LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]); if (!string.IsNullOrEmpty(Request.Query["p"])) { var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poet?url=/{Request.Query["p"]}"); if (!response.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await response.Content.ReadAsStringAsync()); return(Page()); } Poet = JObject.Parse(await response.Content.ReadAsStringAsync()).ToObject <GanjoorPoetCompleteViewModel>().Poet; Poet.ImageUrl = $"{APIRoot.InternetUrl}{Poet.ImageUrl}"; var responseLines = await _httpClient.GetAsync($"{APIRoot.Url}/api/poetspecs/poet/{Poet.Id}"); if (!responseLines.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await responseLines.Content.ReadAsStringAsync()); return(Page()); } SpecLines = JArray.Parse(await responseLines.Content.ReadAsStringAsync()).ToObject <List <GanjoorPoetSuggestedSpecLineViewModel> >(); var responsePhotos = await _httpClient.GetAsync($"{APIRoot.Url}/api/poetphotos/poet/{Poet.Id}"); if (!responsePhotos.IsSuccessStatusCode) { LastError = JsonConvert.DeserializeObject <string>(await responsePhotos.Content.ReadAsStringAsync()); return(Page()); } Photos = JArray.Parse(await responsePhotos.Content.ReadAsStringAsync()).ToObject <List <GanjoorPoetSuggestedPictureViewModel> >(); foreach (var photo in Photos) { photo.ImageUrl = $"{APIRoot.InternetUrl}/{photo.ImageUrl}"; } if (LoggedIn) { await GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData); ModeratePoetPhotos = ViewData.ContainsKey($"{RMuseumSecurableItem.GanjoorEntityShortName}-{RMuseumSecurableItem.ModeratePoetPhotos}"); } } else { Poets = await _PreparePoets(); } ViewData["Title"] = Poet == null ? "پیشنهاد تصویر برای شاعران" : $"پیشنهاد تصویر برای {Poet.Nickname}"; return(Page()); }
private void SetTestResult(string result) { if (ViewData.ContainsKey("TestResult")) { ViewData.Remove("TestResult"); } ViewData.Add("TestResult", result); }
public async Task OnGetAsync(string returnUrl = null) { ReturnUrl = returnUrl; ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (!ViewData.ContainsKey("CompanyName")) { ViewData.Add("CompanyName", await _nodeContext.CompanyName); } }
/// <inheritdoc /> public override Task ExecuteResultAsync(ActionContext context) { if (ViewData.ContainsKey("InAjax") && !ViewData.ContainsKey("HandleKey")) { throw new InvalidOperationException(); } if (!ViewData.ContainsKey("HandleKey2")) { ViewData["HandleKey2"] = Guid.NewGuid().ToString("N")[0..8];
public ActionResult SendMessage(int?pId, string toUid) { //ViewData["title"] = "Message"; Guid ToUserId = toUid.ToGuid(); if (pId == null && toUid == null) { ViewData["title"] = "Messagerie"; ViewData["message"] = "Impossible d'envoyer le message :("; return(PartialView("BlankModal")); } IUserProfile toUser = null; IProjet relatedProjet = null; if (ToUserId.IsEmpty() == false) { toUser = Data.UserDataAccess.GetUser(ToUserId); if (toUser == null) { ViewData["message"] = "Ce message ne peut être envoyé au destinataire indiqué :( "; } } else if (pId.HasValue) { relatedProjet = Data.ProjetDataAccess.GetProjet(pId.Value); if (relatedProjet == null) { ViewData["message"] = "Le projet concernant ce message est introuvable :( "; } } if (ViewData.ContainsKey("message")) { return(PartialView("BlankModal")); } SendMessageViewData sendMessageData = new SendMessageViewData(); if (relatedProjet != null) { sendMessageData.RelatedProjet = relatedProjet; sendMessageData.ToUserProfile = relatedProjet.OwnerUserProfile; sendMessageData.relatedProjetId = relatedProjet.IdProjet.ToString(); sendMessageData.toUserId = relatedProjet.OwnerUserProfile.UserId.ToString(); sendMessageData.sujet = "A propos du voyage n°" + sendMessageData.RelatedProjet.IdProjet + ": " + sendMessageData.RelatedProjet.GetShortDisplayName(); } if (toUser != null) { sendMessageData.ToUserProfile = toUser; sendMessageData.toUserId = toUser.UserId.ToString(); sendMessageData.sujet = ""; } return(PartialView("SendMessageModal", sendMessageData)); }
public HCSWF_dialog_container(SortedList scanCodes, SortedList sl_Check, CnasHCSWorkflowInterface workflowServer, string pd_code, SortedList sL_parametertmp02, DataTable dtpartvalue, SortedList sL_parametersinfo) : base(scanCodes) { _sl_Check = sl_Check; _sL_parametertmp02 = sL_parametertmp02; _pdcode = pd_code; _sL_parametersinfo = sL_parametersinfo; _dtpartvalue = dtpartvalue; Logger = Logger ?? LogManager.GetLogger("CnasWNSClient"); InitializeComponent(); ControlViewBase viewBase = WorkFlowDialogGenerator.Instance.GeneratorWFDialog(PdCode); if (viewBase != null) { _workFlowView = viewBase; DialogResultStatus = viewBase.IsShown ? 1 : 0; _workFlowView.Sl_check = this._sl_Check; _workFlowView.Dock = DockStyle.Fill; infoPanel.Controls.Add(viewBase); infoPanel.SetRow(viewBase, 0); _workFlowView.PdCode = PdCode; _workFlowView.ScanBarCodes = ScanBarCodes; _workFlowView.WorkflowServer = workflowServer as WorkflowArithmeticClass; if (ViewData.ContainsKey("UserInfo") && ViewData["UserInfo"] is UserBase) { viewBase.UserInfo = ViewData["UserInfo"] as UserBase; } else { UserBase userInfo = UserBaseHelper.GetUserByBarCode(BarCodeHelper.GetBarCodeByType("BCB", ScanBarCodes)); if (userInfo != null) { ViewData.Add("UserInfo", userInfo); viewBase.UserInfo = userInfo; } else { Logger.Error(string.Format("Can not get user info. User barCode:{0}", BarCodeHelper.GetBarCodeByType("BCB", ScanBarCodes))); } } MinimumSize = new Size((int)(_workFlowView.Width + mainPanel.ColumnStyles[1].Width + 100), viewBase.Height + 180); } else { DialogResultStatus = 0; } confirmBtn.Height = buttonGroup.ItemHeight - 3; buttonPanel.Height = confirmBtn.Margin.Top + confirmBtn.Margin.Bottom + confirmBtn.Height * 2 + cancelBtn.Margin.Top + cancelBtn.Margin.Bottom; cancelBtn.Height = confirmBtn.Height; confirmBtn.BackgroundImage = BarCodeHelper.GetBarcodeImage(_okBarCode, "确 认", confirmBtn.Width, confirmBtn.Height); cancelBtn.BackgroundImage = BarCodeHelper.GetBarcodeImage(_closeBarCode, "关 闭", cancelBtn.Width, cancelBtn.Height); }
public string GetCurrentController() { if (!ViewData.ContainsKey("CurrentController")) { var displayName = GetCurrentActionDisplayName(); ViewData["CurrentController"] = displayName.Substring(0, displayName.IndexOf("Controller")); } return(ViewData["CurrentController"] as string); }
/// <summary> /// 初始化用户的控件 /// </summary> private void InitalizeUserInfo() { if (ViewData.ContainsKey("UserInfo") && ViewData["UserInfo"] is UserBase) { UserBase userInfo = ViewData["UserInfo"] as UserBase; //userNameTxt.Text = userInfo.UserName; } //else //userNameTxt.Text = CnasBaseData.UserBaseInfo.UserName; }
public string ToView(string viewfile) { FileInfo file = new FileInfo(AppGlobal.AppRootPath + "ModulePlugin\\" + viewfile); if (file.Exists == false) { return("界面文件不存在!"); } #if CSHARP30 TemplateHelper template = new TemplateHelper(file.Directory.FullName); foreach (var dic in ViewData) { template.Put(dic.Key, dic.Value); } string html = template.BuildString(file.Name); return(html); #else if (file.Extension.ToLower() == ".cshtml") { RazorEngine.Razor.SetTemplateBase(typeof(WebAppTemplateBase <>)); if (ViewData.ContainsKey("Razor_Include") == true) { string[] paths = ViewData["Razor_Include"].ToString().Split(new char[] { '|' }); for (int i = 0; i < paths.Length; i++) { FileInfo fileinfo = new FileInfo(AppGlobal.AppRootPath + "ModulePlugin\\" + paths[i]); if (fileinfo.Exists == false) { throw new Exception(fileinfo.Name + "文件不存在!"); } string _html = File.ReadAllText(fileinfo.FullName); RazorEngine.Razor.Compile(_html, paths[i]); } } string html = ""; //if (AppGlobal.Razor_compile) // html = RazorEngine.Razor.Parse(File.ReadAllText(file.FullName), new { ViewData = ViewData, Request = context.Request, Response = context.Response }); //else html = RazorEngine.Razor.Parse(File.ReadAllText(file.FullName), new { ViewData = ViewData, Request = context.Request, Response = context.Response }, viewfile); return(html); } else { TemplateHelper template = new TemplateHelper(file.Directory.FullName); foreach (var dic in ViewData) { template.Put(dic.Key, dic.Value); } string html = template.BuildString(file.Name); return(html); } #endif }