Example #1
0
        public async Task <IActionResult> BillDeliveryEdit(int id, [FromBody] BillDelivery billDelivery)
        {
            if (id != billDelivery.Id)
            {
                Console.WriteLine("Không đúng định dạng");
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(billDelivery);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BillDeliveryExists(billDelivery.Id))
                    {
                        Console.WriteLine("Id không tồn tại");
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(Ok(billDelivery));
        }
Example #2
0
        public override OPResult Save()
        {
            var          lp       = VMGlobal.DistributionQuery.LinqOP;
            BillDelivery delivery = lp.Search <BillDelivery>(o => o.Code == Master.RefrenceBillCode).First();

            delivery.Status = (int)BillDeliveryStatusEnum.已入库;
            //var uniqueCodes = GetSnapshotDetails(delivery.ID);
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    base.SaveWithNoTran();
                    lp.Update <BillDelivery>(delivery);
                    Details.ForEach(d => BillLogic.AddStock(Master.StorageID, d.ProductID, d.Quantity));
                    //SaveUniqueCodes(uniqueCodes);
                    scope.Complete();
                }
                catch (Exception e)
                {
                    return(new OPResult {
                        IsSucceed = false, Message = e.Message
                    });
                }
            }
            return(new OPResult {
                IsSucceed = true
            });
        }
Example #3
0
 public IActionResult BillDeliveryCreate([FromBody] BillDelivery billDelivery)
 {
     try
     {
         BillDelivery test = new BillDelivery();
         test = billDelivery;
         if (ModelState.IsValid)
         {
             _context.Add(test);
             _context.SaveChangesAsync();
             return(Ok(test));
         }
         else
         {
             Console.WriteLine("Không đúng định dạng");
             return(BadRequest());
         }
     }
     catch (ArgumentException err)
     {
         Console.WriteLine("Không đúng định dạng", err);
         return(NotFound());
     }
 }