Example #1
0
        public void Edit(int id, Order order)
        {
            Order entityToEdit = (from cust in _dataContext.Orders
                                  where cust.Id == id
                                  select cust).FirstOrDefault();

            entityToEdit.Amount = order.Amount;
            entityToEdit.ModifiedDate = DateTime.Now;

            _dataContext.SaveChanges();
        }
Example #2
0
        public void Add(int customerId, Order order)
        {
            var addr = new Order
                           {
                               CustomerId = customerId,
                               Amount = order.Amount,
                               ModifiedDate = DateTime.Now
                           };

            _dataContext.Orders.AddObject(addr);
            _dataContext.SaveChanges();
        }
Example #3
0
 public ActionResult Create(int customerId, Order order)
 {
     try
     {
         _repository.Add(customerId, order);
         var orderViewModel = new OrderViewModel
                                  {
                                      Id = order.Id,
                                      CustomerId = order.CustomerId,
                                      Amount = order.Amount,
                                      ModifiedDate = order.ModifiedDate
                                  };
         return RedirectToAction("Index", orderViewModel);
     }
     catch
     {
         return View();
     }
 }
Example #4
0
 public ActionResult Delete(int id, Order order)
 {
     try
     {
         Order toDelete = _repository.Get(id);
         _repository.Delete(id);
         var orderViewModel = new OrderViewModel
                                  {
                                      Id = order.Id,
                                      CustomerId = toDelete.CustomerId,
                                      Amount = toDelete.Amount,
                                      ModifiedDate = toDelete.ModifiedDate
                                  };
         return RedirectToAction("Index", orderViewModel);
     }
     catch
     {
         return View();
     }
 }
Example #5
0
 public void Edit(int orderId, Order order)
 {
     _orderRepository.Edit(orderId, order);
 }
Example #6
0
 public void Add(int customerId, Order order)
 {
     _orderRepository.Add(customerId, order);
 }
Example #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Orders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrders(Order order)
 {
     base.AddObject("Orders", order);
 }
Example #8
0
 /// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="customerId">Initial value of the CustomerId property.</param>
 /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
 public static Order CreateOrder(global::System.Int32 id, global::System.Int32 customerId, global::System.DateTime modifiedDate)
 {
     Order order = new Order();
     order.Id = id;
     order.CustomerId = customerId;
     order.ModifiedDate = modifiedDate;
     return order;
 }