示例#1
0
        public async Task Returning(RetuningInputDto inputdto)
        {
            var isExist = await this.isExists(inputdto.GlobalId);

            if (!isExist)
            {
                throw new Exception($"{inputdto.GlobalId},员工不存在,请检查.");
            }
            var isAvailable = await this.isReturningAvailable(inputdto.BarCode);

            if (!isAvailable)
            {
                throw new Exception($"{inputdto.BarCode},没有找到借书记录,请联系管理员.");
            }
            var checkout = await this.Queryable().Where(x => (x.BarCode == inputdto.BarCode || x.ISBN == inputdto.BarCode) && x.Status == "Pending").FirstAsync();

            var stock = await this.stockService.Queryable().Where(x => (x.BarCode == inputdto.BarCode || x.ISBN == inputdto.BarCode))
                        .FirstAsync();

            stock.Qty = stock.Qty + checkout.Qty;
            this.stockService.Update(stock);
            checkout.BackDate = DateTime.Now;
            checkout.BackQty  = checkout.Qty;
            checkout.Status   = "Returned";
            checkout.Days     = (checkout.BackDate.Value - checkout.BorrowDate).Days + 1;
            this.Update(checkout);
        }
示例#2
0
        public async Task <JsonResult> Returning(RetuningInputDto inputdto)
        {
            try
            {
                await this.checkOutService.Returning(inputdto);

                await this.unitOfWork.SaveChangesAsync();

                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, err = e.GetMessage() }, JsonRequestBehavior.AllowGet));
            }
        }