Ejemplo n.º 1
0
        public IActionResult RestoreStorage([FromBody] string accTranID)
        {
            AccessoryDAO      accDAO = new AccessoryDAO(_context);
            TransactionRelDAO trDAO  = new TransactionRelDAO(_context);
            List <AccessoryTransactionRel> tranList = trDAO.FindByAccTranID(accTranID);
            List <DTO.Accessory>           accList  = new List <DTO.Accessory>();

            foreach (AccessoryTransactionRel tranRel in tranList)
            {
                DTO.Accessory accDTO = accDAO.FindByPrimaryKey(tranRel.AccId);
                accDTO.Quantity += tranRel.Quantity + accDTO.AvailableQuantity;
                accList.Add(accDTO);
            }
            string msg;

            if (accDAO.Restore(accList))
            {
                msg = "Restore all canceled accessories success";
            }
            else
            {
                msg = "Restore all canceled accessories failed";
            }
            return(new JsonResult(msg));
        }