Example #1
0
        public void Delete(Guid orderId)
        {
            var db = new Models.OrdersEntities();

            var del = (from d in db.Orders where d.Id == orderId select d).Single();

            db.Orders.Remove(del);
            db.SaveChanges();

            db.Dispose();
        }
Example #2
0
        public void Update()
        {
            var db = new Models.OrdersEntities();

            Models.Customer customer = (from d in db.Customers where d.Id == this.Model.Id select d).Single();

            customer.FirstName = this.Model.FirstName;
            customer.LastName  = this.Model.LastName;

            db.SaveChanges();

            db.Dispose();
        }
Example #3
0
        public Guid Insert(Guid customerId, string referenceNumber, decimal orderValue)
        {
            var db = new Models.OrdersEntities();

            var order = new Models.Order {
                Id              = Guid.NewGuid(),
                CustomerId      = customerId,
                ReferenceNumber = referenceNumber,
                OrderValue      = orderValue,
                OrderDate       = DateTime.Now
            };

            db.Orders.Add(order);
            db.SaveChanges();

            db.Dispose();

            return(order.Id);
        }