Beispiel #1
0
        public void WriteOrderToDB([FromBody] Order value)
        {
            var db = new OrderModelDataContext();

            value.DateCreated = DateTime.Today;
            db.Orders.InsertOnSubmit(value);
            db.SubmitChanges();
        }
Beispiel #2
0
        public void UpdateOrderInDB([FromBody] Order value, string key)
        {
            var db            = new OrderModelDataContext();
            int keyValueAsInt = Int32.Parse(key);
            var query         = from Order in db.Orders
                                where Order.OrderId == keyValueAsInt
                                select Order;

            var orderInDB = query.First();

            #region changeDb
            if (orderInDB.CompanyId != value.CompanyId)
            {
                orderInDB.CompanyId = value.CompanyId;
            }
            if (orderInDB.CompanyName != value.CompanyName)
            {
                orderInDB.CompanyName = value.CompanyName;
            }
            if (orderInDB.ContactPerson != value.ContactPerson)
            {
                orderInDB.ContactPerson = value.ContactPerson;
            }
            if (orderInDB.Deadline != value.Deadline)
            {
                orderInDB.Deadline = value.Deadline;
            }
            if (orderInDB.Description != value.Description)
            {
                orderInDB.Description = value.Description;
            }
            if (orderInDB.Person != value.Person)
            {
                orderInDB.Person = value.Person;
            }
            if (orderInDB.PriorityNumber != value.PriorityNumber)
            {
                orderInDB.PriorityNumber = value.PriorityNumber;
            }
            if (orderInDB.Headline != value.Headline)
            {
                orderInDB.Headline = value.Headline;
            }
            #endregion

            db.SubmitChanges();
        }