public IHttpActionResult PutPurchase_order(int id, Purchase_order purchase_order)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            if (id != purchase_order.pd_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public PurchaseViewModel GetAsset_master(string ordno)
        {
            db.Configuration.ProxyCreationEnabled = true;
            Purchase_order    x       = db.Purchase_order.Where(y => y.pd_order_no == ordno).FirstOrDefault();
            PurchaseViewModel pvModel = new PurchaseViewModel();

            if (x == null)
            {
            }
            else
            {
                pvModel.pd_id          = x.pd_id;
                pvModel.pd_order_no    = x.pd_order_no;
                pvModel.pd_ad_id       = x.pd_ad_id;
                pvModel.pd_ad_name     = x.Asset_def.ad_name;
                pvModel.pd_dateStr     = x.pd_dateStr;
                pvModel.pd_ddateStr    = x.pd_ddateStr;
                pvModel.pd_qty         = Convert.ToInt32(x.pd_qty);
                pvModel.pd_status      = x.pd_status;
                pvModel.pd_type_id     = x.pd_type_id;
                pvModel.pd_type_name   = x.Asset_type.at_name;
                pvModel.pd_vendor_id   = x.pd_vendor_id;
                pvModel.pd_vendor_name = x.vendor.vd_name;
            }
            return(pvModel);
        }
コード例 #3
0
        public IHttpActionResult PutPurchase_order(int id, Purchase_order purchase_Order)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}

            //if (id != asset_master.am_id)
            //{
            //    return BadRequest();
            //}

            //db.Entry(asset_master).State = EntityState.Modified;

            //try
            //{
            //    db.SaveChanges();
            //}
            //catch (DbUpdateConcurrencyException)
            //{
            //    if (!Asset_masterExists(id))
            //    {
            //        return NotFound();
            //    }
            //    else
            //    {
            //        throw;
            //    }
            //}
            count = Convert.ToDecimal(purchase_Order.pd_qty);
            db.Entry(purchase_Order).State = EntityState.Modified;
            db.SaveChanges();
            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostPurchase_order(Purchase_order purchase_order)
        {
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}
            purchase_order.pd_date = DateTime.Now;
            db.Purchase_order.Add(purchase_order);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = purchase_order.pd_id }, purchase_order));
        }
        public IHttpActionResult PostPurchase_order(Purchase_order purchase_order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Purchase_order.Add(purchase_order);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = purchase_order.pd_id }, purchase_order));
        }
        public IHttpActionResult DeletePurchase_order(int id)
        {
            Purchase_order purchase_order = db.Purchase_order.Find(id);

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

            db.Purchase_order.Remove(purchase_order);
            db.SaveChanges();

            return(Ok(purchase_order));
        }
        public PurchaseViewModel GetPurchase_order(int id)
        {
            db.Configuration.ProxyCreationEnabled = true;

            Purchase_order    pOrder  = db.Purchase_order.Where(x => x.pd_id == id).FirstOrDefault();
            PurchaseViewModel pvModel = new PurchaseViewModel();

            pvModel.pd_id        = pOrder.pd_id;
            pvModel.pd_order_no  = pOrder.pd_order_no;
            pvModel.pd_ad_id     = pOrder.pd_ad_id;
            pvModel.pd_ad        = pOrder.Asset_def.ad_name;
            pvModel.pd_dateStr   = pOrder.pd_dateStr;
            pvModel.pd_ddateStr  = pOrder.pd_ddateStr;
            pvModel.pd_qty       = Convert.ToInt32(pOrder.pd_qty);
            pvModel.pd_status    = pOrder.pd_status;
            pvModel.pd_type_id   = pOrder.pd_type_id;
            pvModel.pd_type      = pOrder.Asset_type.at_name;
            pvModel.pd_vendor_id = pOrder.pd_vendor_id;
            pvModel.pd_vendor    = pOrder.vendor.vd_name;

            return(pvModel);
        }