コード例 #1
0
        public Task <AddNewQuotationResponse> addNewQuotation(AddNewQuotationRequest request)
        {
            AddNewQuotationResponse response = new AddNewQuotationResponse();
            CustomerModel           customer = _customerService.GetByCode(request.customer_code);

            if (customer == null)
            {
                return(Task.FromResult(response));
            }
            AddNewQuotationCommand command = new AddNewQuotationCommand
                                             (
                customer.ID,
                request.date
                                             );
            Task <object> Quotation = (Task <object>)Bus.SendCommand(command);

            //RabbitMQBus.Publish(command);

            response = Common <AddNewQuotationResponse> .checkHasNotification(_notifications, response);

            if (response.Success)
            {
                QuotationModel QuotationModel = (QuotationModel)Quotation.Result;
                response.Data = QuotationModel.ID;
            }
            return(Task.FromResult(response));
        }
コード例 #2
0
 public Task<AddNewCustomerResponse> addNewCustomer(AddNewCustomerRequest request)
 {
     AddNewCustomerCommand command = new AddNewCustomerCommand(
             request.Name,
             request.Note,
             request.CartCode,
             request.PhoneNumber,
             request.Email,
             request.Code,
             request.Status,
             request.Address.City,
             request.Address.Country,
             request.Address.District,
             request.Address.Street,
             request.Address.StreetNumber,
              request.Address.Lat.ToString(),
             request.Address.Lng.ToString()
         );
     Task<object> Customer = (Task<object>)Bus.SendCommand(command);
     RabbitMQBus.Publish(command);
     AddNewCustomerResponse response = new AddNewCustomerResponse();
     response = Common<AddNewCustomerResponse>.checkHasNotification(_notifications, response);
     if (response.Success)
     {
         CustomerModel CustomerModel = (CustomerModel)Customer.Result;
         //them bao gia
         AddNewQuotationRequest request2 = new AddNewQuotationRequest()
         {
             customer_code = CustomerModel.Code,
             date = DateTime.Now
         };
         _QuotationAppService.addNewQuotation(request2);
         response.Data = CustomerModel.ID;
     }
     return Task.FromResult(response);
 }
コード例 #3
0
        public async Task <IActionResult> ImportQuotation([FromQuery] AddNewQuotationRequest request)
        {
            IFormFile file  = Request.Form.Files[0];
            ISheet    sheet = ImportExcelCommon.GetSheetFromFile(file, "Quotation\\Customer_" + request.customer_code);

            if (sheet != null)
            {
                IRow headerRow = sheet.GetRow(11); //Get Header Row
                int  cellCount = headerRow.LastCellNum;
                int  startRow  = 12;
                int  lastRow   = sheet.LastRowNum;
                //thuc hien them moi dot bao gia cho khach hang
                int QuotationId = (await _QuotationAppService.addNewQuotation(request)).Data;
                if (QuotationId <= 0)
                {
                    return(BadRequest());
                }
                //them cac san pham vao dot bao gia
                for (int i = startRow; i <= lastRow; i++) //Read Excel File
                {
                    IRow row = sheet.GetRow(i);
                    if (row == null)
                    {
                        continue;
                    }
                    if (row.Cells.All(d => d.CellType == CellType.Blank))
                    {
                        continue;
                    }
                    int startCell = row.FirstCellNum + 1;

                    AddNewQuotationItemRequest itemRequest = new AddNewQuotationItemRequest();
                    string code = row.GetCell(startCell++).ToString();
                    if (string.IsNullOrWhiteSpace(code))
                    {
                        continue;
                    }
                    itemRequest.ProductCode = code;
                    itemRequest.QuotationID = QuotationId;
                    //gia
                    int price = -1;
                    Int32.TryParse(row.GetCell(4).ToString(), out price);
                    if (price == -1)
                    {
                        continue;
                    }
                    itemRequest.Price = price;


                    UnitModel unit = _UnitRepository.GetByName(row.GetCell(3).ToString().ToLower());
                    if (unit == null)
                    {
                        continue;
                    }
                    itemRequest.UnitID = unit.ID;


                    await _QuotationItemAppService.addNewQuotation(itemRequest);
                }
                return(Ok());
            }
            return(BadRequest());
        }