Exemplo n.º 1
0
        public ActionResult Edit(RateViewModel model)
        {
            if (SessionVars.UserName.IsNullOrWhiteSpace())
            {
                return(RedirectToAction("Login", new { controller = "Account" }));
            }

            if (ModelState.IsValid)
            {
                model.UpdatedBy = SessionVars.UserName;
                model.SaveViewModel();
                TempData["Success"] = "Program updated successfully!";
                return(RedirectToAction("Edit", new { controller = "Rate", id = model.Id }));
            }

            //if selected vendors is null initialize it
            model.SelectedVendors = model.SelectedVendors ?? new List <int>();

            model.SetDropdowns();
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Create(RateViewModel newProgram)
        {
            if (SessionVars.UserName.IsNullOrWhiteSpace())
            {
                return(RedirectToAction("Login", new { controller = "Account" }));
            }

            if (ModelState.IsValid)
            {
                newProgram.Id        = null;
                newProgram.UpdatedBy = SessionVars.UserName;
                newProgram.SaveViewModel();

                TempData["Success"] = "Program created successfully!";
                return(RedirectToAction("Edit", new { controller = "Rate", id = newProgram.Id }));
            }

            //if selected vendors or SalesChannels is null initialize it
            newProgram.SelectedVendors       = newProgram.SelectedVendors ?? new List <int>();
            newProgram.SelectedSalesChannels = newProgram.SelectedSalesChannels ?? new List <int>();
            newProgram.SetDropdowns();
            return(View(newProgram));
        }