Exemplo n.º 1
0
 public ActionResult Create(int productId, Promotion promotion)
 {
     try
     {
         _repository.Add(productId, promotion);
         var promotionViewModel = new PromotionViewModel
         {
             Id = promotion.Id,
             ProductId = promotion.ProductId,
             SalesStartDate = promotion.SalesStartDate,
             SalesEndDate = promotion.SalesEndDate,
             PercentDiscount = promotion.PercentDiscount,
             ModifiedDate = promotion.ModifiedDate
         };
         return RedirectToAction("Index", promotionViewModel);
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 2
0
        public ActionResult Details(int id)
        {
            Promotion promotion = _repository.Get(id);
            var promotionViewModel = new PromotionViewModel
            {
                Id = promotion.Id,
                ProductId = promotion.ProductId,
                SalesStartDate = promotion.SalesStartDate,
                SalesEndDate = promotion.SalesEndDate,
                PercentDiscount = promotion.PercentDiscount,
                ModifiedDate = promotion.ModifiedDate
            };

            return promotionViewModel.Id > 0 ? View(promotionViewModel) : View("No data found");
        }
Exemplo n.º 3
0
 public ActionResult Index()
 {
     IEnumerable<Promotion> promotions = _repository.List();
     var promotionViewModels = new List<PromotionViewModel>();
     foreach (Promotion promotion in promotions)
     {
         var promotionViewModel = new PromotionViewModel()
         {
             Id = promotion.Id,
             ProductId = promotion.ProductId,
             SalesStartDate = promotion.SalesStartDate,
             SalesEndDate = promotion.SalesEndDate,
             PercentDiscount = promotion.PercentDiscount,
             ModifiedDate = promotion.ModifiedDate
         };
         promotionViewModels.Add(promotionViewModel);
     }
     return promotions.Count() > 0 ? View(promotionViewModels) : View("No data found");
 }
Exemplo n.º 4
0
 public ActionResult Edit(int id)
 {
     var promotion = _repository.Get(id);
     var promotionViewModel = new PromotionViewModel
     {
         Id = promotion.Id,
         ProductId = promotion.ProductId,
         SalesStartDate = promotion.SalesStartDate,
         SalesEndDate = promotion.SalesEndDate,
         PercentDiscount = promotion.PercentDiscount,
         ModifiedDate = promotion.ModifiedDate
     };
     return View(promotionViewModel);
 }