public override Dictionary <string, object> ViewDataValues(NamesHelper h) { var viewDataValues = new Dictionary <string, object>(); viewDataValues.Add("RegionCodeEqual", h.GetRegionList(Id)); viewDataValues.Add("CatalogIdEqual", h.GetCatalogList()); viewDataValues.Add("CatalogIdEqual2", h.GetCatalogList(CatalogIdEqual2)); return(viewDataValues); }
public override Dictionary <string, object> ViewDataValues(NamesHelper h) { return(new Dictionary <string, object> { { "RegionCodeEqual", h.GetRegionList(Id) }, { "CatalogIdEqual", h.GetCatalogList() } }); }
private JsonResult ToJson(Promotion model) { var viewModel = new PromotionUi(); viewModel.DrugCatalogList = h.GetCatalogList().Select(x => new TextValue { Text = x.Text, Value = x.Value }).ToList(); viewModel.RegionGlobalList = DB.Regions().Select(x => new TextValue(x)).ToList(); viewModel.Id = model.Id; viewModel.Name = model.Name; viewModel.Annotation = model.Annotation; if (model.MediaFile != null) { viewModel.PromotionFileId = model.MediaFile.Id; viewModel.PromotionFileName = model.MediaFile.ImageName; viewModel.PromotionFileUrl = Url.Action("GetFile", "MediaFiles", new { model.MediaFile.Id }); } if (model.Id == 0) { viewModel.Title = "Новая промоакция"; } else { viewModel.Title = "Редактирование промоакции: " + model.Name; } viewModel.PromotionFileId = model.MediaFile?.Id; if (model.Begin < DateTime.Now) { viewModel.Begin = DateTime.Now.ToString("dd.MM.yyyy"); } else { viewModel.Begin = model.Begin.ToString("dd.MM.yyyy"); } if (model.End < DateTime.Now) { viewModel.End = DateTime.Now.ToString("dd.MM.yyyy"); } else { viewModel.End = model.End.ToString("dd.MM.yyyy"); } viewModel.DrugList = model.PromotionToDrug.ToList().Select(x => x.DrugId.ToString()).ToList(); var regions = DB.Regions((ulong)model.RegionMask); viewModel.RegionList = regions.Select(x => x.Id.ToString()).ToList(); if (model.AllSuppliers) { viewModel.SuppierRegions = new List <string>() { "0" } } ; else { viewModel.SuppierRegions = model.PromotionsToSupplier.Select(x => x.SupplierId.ToString()).ToList(); } viewModel.SuppierRegionsList = h.GetSupplierList(regions.Select(x => x.Id).ToList()) .Select(x => new TextValue { Text = x.Text, Value = x.Value }) .ToList(); viewModel.SuppierRegionsList.Add(new TextValue() { Text = "Все поставщики из выбранных регионов", Value = "0" }); return(Json(viewModel, JsonRequestBehavior.AllowGet)); }