Beispiel #1
0
        public IHttpActionResult PostRecycleOrder_RecycleEvaluatonChoice(RecycleOrder_RecycleEvaluatonChoice recycleOrder_RecycleEvaluatonChoice)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.RecycleOrder_RecycleEvaluatonChoice.Add(recycleOrder_RecycleEvaluatonChoice);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (RecycleOrder_RecycleEvaluatonChoiceExists(recycleOrder_RecycleEvaluatonChoice.Rec_order_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = recycleOrder_RecycleEvaluatonChoice.Rec_order_ID }, recycleOrder_RecycleEvaluatonChoice));
        }
Beispiel #2
0
        public IHttpActionResult PutRecycleOrder_RecycleEvaluatonChoice(int id, RecycleOrder_RecycleEvaluatonChoice recycleOrder_RecycleEvaluatonChoice)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != recycleOrder_RecycleEvaluatonChoice.Rec_order_ID)
            {
                return(BadRequest());
            }

            db.Entry(recycleOrder_RecycleEvaluatonChoice).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RecycleOrder_RecycleEvaluatonChoiceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IHttpActionResult GetRecycleOrder_RecycleEvaluatonChoice(int id)
        {
            RecycleOrder_RecycleEvaluatonChoice recycleOrder_RecycleEvaluatonChoice = db.RecycleOrder_RecycleEvaluatonChoice.Find(id);

            if (recycleOrder_RecycleEvaluatonChoice == null)
            {
                return(NotFound());
            }

            return(Ok(recycleOrder_RecycleEvaluatonChoice));
        }
        public IHttpActionResult PostUserAddress(OrderData recycleOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (getCooikedUser() == null)
            {
                return(Unauthorized());
            }

            RecycleOrder order = new RecycleOrder();

            order.Create_time   = System.DateTime.Now;
            order.Service_time  = recycleOrder.Service_time;
            order.Customer_note = recycleOrder.Customer_note;
            order.Staff_note    = recycleOrder.Staff_note;
            order.Price         = recycleOrder.Price;
            order.State         = recycleOrder.State;
            order.Loc_name      = recycleOrder.Loc_name;
            order.Loc_detail    = recycleOrder.Loc_detail;
            order.Customer_ID   = getCooikedUser().ID;
            order.Engineer_ID   = null;



            var entry = db.RecycleOrders.Add(order);

            db.SaveChanges();

            db.Entry(order).GetDatabaseValues();

            Console.WriteLine(order.ID);

            foreach (var choice in recycleOrder.Choices)
            {
                var recycleOrderRecycleEvaluationChoice =
                    new RecycleOrder_RecycleEvaluatonChoice
                {
                    Rec_eval_choice_ID = choice,
                    Rec_order_ID       = order.ID
                };

                db.RecycleOrder_RecycleEvaluatonChoice.Add(recycleOrderRecycleEvaluationChoice);
                db.SaveChanges();
            }



            return(CreatedAtRoute("GetUserRecycleOrder", new { id = order.ID }, order));
        }
Beispiel #5
0
        public IHttpActionResult DeleteRecycleOrder_RecycleEvaluatonChoice(int id)
        {
            RecycleOrder_RecycleEvaluatonChoice recycleOrder_RecycleEvaluatonChoice = db.RecycleOrder_RecycleEvaluatonChoice.Find(id);

            if (recycleOrder_RecycleEvaluatonChoice == null)
            {
                return(NotFound());
            }

            db.RecycleOrder_RecycleEvaluatonChoice.Remove(recycleOrder_RecycleEvaluatonChoice);
            db.SaveChanges();

            return(Ok(recycleOrder_RecycleEvaluatonChoice));
        }