Esempio n. 1
0
        public ActionResult Create(CatalogCampaignsEditViewModel model, FormCollection frm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    m_catalogWorker.InsertManagerCatalogCampaign(model);
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("General", ex.Message);
                }
            }
            this.StatusList(model.Status);
            this.Pair2List <CatalogCampaignsEditViewModel, short, short>(CatalogCampaignsListProvider.GetCapaignMethodList(), m => m.CampaignMethod, model.CampaignMethod.ToString());
            this.Pair2List <CatalogCampaignsEditViewModel, short, short>(CatalogCampaignsListProvider.GetDiscountMethodList(), m => m.DiscountMethod, model.DiscountMethod.ToString());
            var sources = model.Sources.Select(s => new CatalogCampaignsSourceTransformViewModel {
                Id = s.ProductId, Text = s.ProductName
            }).ToList();
            var destinations = model.Destinations.Select(s => new CatalogCampaignsSourceTransformViewModel {
                Id = s.ProductId, Text = s.ProductName
            }).ToList();

            ViewBag.SourceProds       = Newtonsoft.Json.JsonConvert.SerializeObject(sources);
            ViewBag.DestinationsProds = Newtonsoft.Json.JsonConvert.SerializeObject(destinations);
            return(View(model));
        }
Esempio n. 2
0
        //GET: Admin/CampaignManager/Create
        public ActionResult Create()
        {
            this.StatusList(1);
            this.Pair2List <CatalogCampaignsEditViewModel, short, short>(CatalogCampaignsListProvider.GetCapaignMethodList(), m => m.CampaignMethod, null);
            this.Pair2List <CatalogCampaignsEditViewModel, short, short>(CatalogCampaignsListProvider.GetDiscountMethodList(), m => m.DiscountMethod, null);
            var model = new CatalogCampaignsEditViewModel {
                Status = 1, StartDate = DateTime.Today, EndDate = DateTime.Today
            };

            model.Sources      = new List <CatalogCampaignsSourcesViewModel>();
            model.Destinations = new List <CatalogCampaignsDestinationsViewModel>();
            return(View(model));
        }
Esempio n. 3
0
        //GET: Admin/CampaignManager/Edit
        public ActionResult Edit(int id)
        {
            var model = m_catalogWorker.GetManagerCatalogCampaignsEdit(id);

            this.StatusList(model.Status);
            this.Pair2List <CatalogCampaignsEditViewModel, short, short>(CatalogCampaignsListProvider.GetCapaignMethodList(), m => m.CampaignMethod, model.CampaignMethod.ToString());
            this.Pair2List <CatalogCampaignsEditViewModel, short, short>(CatalogCampaignsListProvider.GetDiscountMethodList(), m => m.DiscountMethod, model.DiscountMethod.ToString());
            var sources = model.Sources.Select(s => new CatalogCampaignsSourceTransformViewModel {
                Id = s.ProductId, Text = s.ProductName
            }).ToList();

            int[] sourceIds    = sources.Select(s => s.Id).ToArray();
            var   destinations = model.Destinations.Select(s => new CatalogCampaignsSourceTransformViewModel {
                Id = s.ProductId, Text = s.ProductName
            }).ToList();

            int[] destIds = destinations.Select(s => s.Id).ToArray();
            ViewBag.SourceProds       = Newtonsoft.Json.JsonConvert.SerializeObject(sources);
            ViewBag.DestinationsProds = Newtonsoft.Json.JsonConvert.SerializeObject(destinations);
            ViewBag.SourceIds         = Newtonsoft.Json.JsonConvert.SerializeObject(sourceIds);
            ViewBag.DestinationIds    = Newtonsoft.Json.JsonConvert.SerializeObject(destIds);
            return(View(model));
        }