Ejemplo n.º 1
0
        public void Delete(int id, Promotion promotion)
        {
            Promotion entity = (from promo in _dataContext.Promotions
                                where promo.Id == id
                                select promo).FirstOrDefault();

            _dataContext.DeleteObject(entity);
            _dataContext.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Edit(int id, Promotion promotion)
        {
            Promotion entityToEdit = (from cust in _dataContext.Promotions
                                      where cust.Id == id
                                      select cust).FirstOrDefault();

            entityToEdit.ProductId = promotion.ProductId;
            entityToEdit.SalesStartDate = promotion.SalesStartDate;
            entityToEdit.PercentDiscount = promotion.PercentDiscount;
            entityToEdit.SalesEndDate = promotion.SalesEndDate;
            entityToEdit.ModifiedDate = DateTime.Now;

            _dataContext.SaveChanges();
        }
Ejemplo n.º 3
0
        public void Add(int productId, Promotion promotion)
        {
            var entity = new Promotion
                             {
                                 ProductId = productId,
                                 SalesEndDate = promotion.SalesEndDate,
                                 SalesStartDate = promotion.SalesStartDate,
                                 PercentDiscount = promotion.PercentDiscount,
                                 ModifiedDate = DateTime.Now
                             };

            _dataContext.Promotions.AddObject(entity);
            _dataContext.SaveChanges();
        }
Ejemplo n.º 4
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();
     }
 }
Ejemplo n.º 5
0
 public void Edit(int id, Promotion promotion)
 {
     _promotionRepository.Edit(id, promotion);
 }
Ejemplo n.º 6
0
 public void Delete(int Id, Promotion promotion)
 {
     _promotionRepository.Delete(Id, promotion);
 }
Ejemplo n.º 7
0
 public void Add(int id, Promotion promotion)
 {
     _promotionRepository.Add(id, promotion);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Promotions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPromotions(Promotion promotion)
 {
     base.AddObject("Promotions", promotion);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Create a new Promotion object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="productId">Initial value of the ProductId property.</param>
 /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
 public static Promotion CreatePromotion(global::System.Int32 id, global::System.Int32 productId, global::System.DateTime modifiedDate)
 {
     Promotion promotion = new Promotion();
     promotion.Id = id;
     promotion.ProductId = productId;
     promotion.ModifiedDate = modifiedDate;
     return promotion;
 }