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(); }
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(); }
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(); }
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(); } }
public void Edit(int id, Promotion promotion) { _promotionRepository.Edit(id, promotion); }
public void Delete(int Id, Promotion promotion) { _promotionRepository.Delete(Id, promotion); }
public void Add(int id, Promotion promotion) { _promotionRepository.Add(id, promotion); }
/// <summary> /// Deprecated Method for adding a new object to the Promotions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPromotions(Promotion promotion) { base.AddObject("Promotions", promotion); }
/// <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; }