示例#1
0
        public ActionResult Index()
        {
            ViewBag.Title = Properties.Resources.titleEditList;
            ViewBag.Location = Properties.Resources.menuEditList;
            NewListViewModel model = new NewListViewModel();

            return View("List", model);
        }
示例#2
0
 public ActionResult Save(NewListViewModel updatedModel, string submitButtonValue)
 {
     if (ModelState.IsValid)
     {
         if (submitButtonValue == Resources.btnAddArticle)
         {
             return AddArticle(updatedModel);
         }
         else
         {
             if (submitButtonValue == Resources.btnSaveList)
             {
                 return SaveList(updatedModel);
             }
         }
         throw new Exception("Unknown button name");
     }
     else
     {
         return View("List", updatedModel);
     }
 }
示例#3
0
        private ActionResult AddArticle(NewListViewModel updatedModel)
        {
            if (!string.IsNullOrEmpty(updatedModel.SelectedArticleId) && this.dao.GetArticles().Where(x => x.Name == updatedModel.SelectedArticleId).Count() == 0)
            {
                this.dao.AddArticle(updatedModel.SelectedArticleId);
            }

            if (!string.IsNullOrEmpty(updatedModel.SelectedDetailColorId) && this.dao.GetDetails().Where(x => x.Name == updatedModel.SelectedDetailColorId).Count() == 0)
            {
                this.dao.AddDetail(updatedModel.SelectedDetailColorId);
            }

            if (!string.IsNullOrEmpty(updatedModel.SelectedBrandId) && this.dao.GetBrandReferences().Where(x => x.Name == updatedModel.SelectedBrandId).Count() == 0)
            {
                this.dao.AddBrand(updatedModel.SelectedBrandId);
            }

            if (!string.IsNullOrEmpty(updatedModel.SelectedSizeId) && this.dao.GetSizes().Where(x => x.Name == updatedModel.SelectedSizeId).Count() == 0)
            {
                this.dao.AddSize(updatedModel.SelectedSizeId);
            }

            if (!string.IsNullOrEmpty(updatedModel.SelectedPriceId) && this.dao.GetPrices().Where(x => x.Name == updatedModel.SelectedPriceId).Count() == 0)
            {
                this.dao.AddPrice(updatedModel.SelectedPriceId);
            }

            updatedModel.ListBO.Article.Add(new Article()
            {
                Name = updatedModel.SelectedArticleId,
                Details = updatedModel.SelectedDetailColorId,
                Brand = updatedModel.SelectedBrandId,
                Price = double.Parse(updatedModel.SelectedPriceId.Replace('.', ',')),
                Size = updatedModel.SelectedSizeId,
                isToy = updatedModel.isAToy
            });

            // Save the current list
            this.dao.SaveList(updatedModel.ListBO);

            // Reset
            ResetCurrentArticle(ref updatedModel);

            return View("List", updatedModel);
        }
示例#4
0
        private ActionResult SaveList(NewListViewModel updatedModel)
        {
            this.dao.SaveList(updatedModel.ListBO);

            ResetCurrentArticle(ref updatedModel);

            return View("List", updatedModel);
        }
示例#5
0
 private static void ResetCurrentArticle(ref NewListViewModel updatedModel)
 {
     updatedModel.SelectedArticleId = string.Empty;
     updatedModel.SelectedDetailColorId = string.Empty;
     updatedModel.SelectedBrandId = string.Empty;
     updatedModel.SelectedPriceId = string.Empty;
     updatedModel.SelectedSizeId = string.Empty;
     updatedModel.isAToy = false;
 }