Esempio n. 1
0
        public async Task Confirm(CustomerConfirmDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }
            var order = await DbContext.OnlineOrder.Where(o => o.OrderId == dto.Id).SingleOrDefaultAsync() ??
                        throw new BussinessException($"Order: {dto.Id} is not exists");

            //Stage check
            if (order.StageId != (int)StageEnum.CustomerConfirm)
            {
                throw new BussinessException($"Order: {dto.Id} stage is not valid for customer confirm");
            }
            //Must be the assignee of case to confirm
            if (order.AssignUserId != UserId)
            {
                throw new BussinessException($"Order: {dto.Id} is not assigned to current user");
            }
            //Proceed
            if (dto.Confirm)
            {
                order.StageId = (int)StageEnum.EnterContractNumber;
            }
            else
            {
                order.StageId = (int)StageEnum.CustomerReject;
                _mail.MailStageChanged(order, StageEnum.CustomerReject.ToString(), Email, null);
            }
            await DbContext.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task DocumentConfirm(CustomerConfirmDTO dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }
            var order = await DbContext.OnlineOrder.Where(o => o.OrderId == dto.Id).SingleOrDefaultAsync() ??
                        throw new BussinessException($"Order: {dto.Id} is not exists");

            if (order.StageId != (int)StageEnum.WaitForDocument)
            {
                throw new BussinessException($"Order: {dto.Id} stage is not valid for document confirm");
            }
            //Must be the assignee of case to confirm
            if (order.AssignUserId != UserId)
            {
                throw new BussinessException($"Order: {dto.Id} is not assigned to current user");
            }
            if (dto.Confirm)
            {
                //Proceed to wait for online bill
                order.StageId = (int)StageEnum.WaitForOnlineBill;
            }
            else
            {
                //Back to enter contract number
                order.StageId = (int)StageEnum.EnterContractNumber;
                //Clear indus contract
                order.Induscontract = null;
            }
            await DbContext.SaveChangesAsync();
        }
Esempio n. 3
0
        public async Task <IActionResult> DocumentConfirm([FromBody] CustomerConfirmDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            try
            {
                await _service.DocumentConfirm(dto);

                return(Ok());
            }
            catch (BussinessException ex)
            {
                _logger.LogDebug(ex.Message);
                return(BadRequest(ex.Message));
            }
        }