示例#1
0
        public async Task <IHttpActionResult> PutFinishedGood(int id, FinishedGood finishedGood)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != finishedGood.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FinishedGoodExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public ActionResult Edit(FinishedGood fg)
        {
            if (fg.Id != 0)
            {
                var vendorIbDB = _capitaContext.FinishedGoods.Single(v => v.Id == fg.Id);
                fg.ProductCode         = fg.ProductName.Substring(0, 4) + "00" + fg.ShortColorCode.Substring(0, 3) + fg.Capacity;
                vendorIbDB.ProductName = fg.ProductName;
                vendorIbDB.ProductCode = fg.ProductCode;
                vendorIbDB.CellType    = fg.CellType;
                vendorIbDB.Capacity    = fg.Capacity;
                vendorIbDB.Color       = fg.Color;
                vendorIbDB.Brand       = fg.Brand;

                vendorIbDB.ShortBrandCode   = fg.ShortBrandCode;
                vendorIbDB.ShortColorCode   = fg.ShortColorCode;
                vendorIbDB.ShortProductName = fg.ShortProductName;
                vendorIbDB.UOM   = fg.UOM;
                vendorIbDB.Stock = fg.Stock;
                vendorIbDB.GST   = fg.GST;

                vendorIbDB.Rate = fg.Rate;
                vendorIbDB.MIN  = fg.MIN;
                vendorIbDB.Max  = fg.Max;
                vendorIbDB.SAC  = fg.SAC;
            }
            _capitaContext.SaveChanges();
            return(RedirectToAction("Index", "FinishedGood"));
        }
示例#3
0
        public async Task <IHttpActionResult> GetFinishedGood(int id)
        {
            FinishedGood finishedGood = await db.FinishedGoods.FindAsync(id);

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

            return(Ok(finishedGood));
        }
示例#4
0
        public async Task <IHttpActionResult> PostFinishedGood(FinishedGood finishedGood)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.FinishedGoods.Add(finishedGood);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = finishedGood.Id }, finishedGood));
        }
示例#5
0
        public async Task <IHttpActionResult> DeleteFinishedGood(int id)
        {
            FinishedGood finishedGood = await db.FinishedGoods.FindAsync(id);

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

            db.FinishedGoods.Remove(finishedGood);
            await db.SaveChangesAsync();

            return(Ok(finishedGood));
        }