예제 #1
0
        public async Task <IActionResult> PostStockOrder()
        {
            var response = await _apiClient.HttpClient.GetAsync("TenantSetting/ViewSetting");

            if (response.IsSuccessStatusCode)
            {
                var data = await response.Content.ReadAsStringAsync();

                var setting = JsonConvert.DeserializeObject <TenantSetting>(data);
                ViewData["BaseUrl"] = setting.BaseUrl;
            }
            var model = new CustomerRequirementModel();

            model.Sites = await GetSitesList();

            model.Locations = await GetLocationsList();

            model.Employees = await GetEmployeesList();

            model.Accounts = await GetAccountsList();

            return(View(model));
        }
예제 #2
0
        public async Task <IActionResult> UploadStockTransfer([FromForm] CustomerRequirementModel model)
        {
            if (model.FileTemplate != null || model.FileTemplate.Length > 0)
            {
                using (var ms = new MemoryStream())
                {
                    model.FileTemplate.CopyTo(ms);
                    ms.Seek(0, SeekOrigin.Begin);

                    var response = await _applicationServices.UploadStockTransfer(ms, new StockTransferModel
                    {
                        ShipFromSiteID   = model.ShipFromSiteID,
                        ShipToSiteID     = model.ShipToSiteID,
                        ShipToLocationID = model.ShipToLocationID,
                        CompleteDeliveryRequestedIndicator = model.CompleteDeliveryRequestedIndicator ? "true" : "false",
                        DeliveryPriorityCode    = model.DeliveryPriorityCode,
                        RaiseSalesQuote         = model.RaiseSalesQuote,
                        AccountId               = model.AccountId,
                        Description             = model.Description,
                        DistributionChannelCode = model.DistributionChannelCode,
                        EmployeeResponsible     = model.EmployeeResponsible,
                        ExternalReference       = model.ExternalReference,
                        PostingDate             = model.PostingDate.Value,
                        SalesUnitId             = model.SalesUnitId,
                        RequestedDate           = model.RequestedDate.Value
                    });

                    if (response != null)
                    {
                        return(Ok(response));
                    }
                }
            }

            return(null);
        }
예제 #3
0
        public async Task <IActionResult> PostStockOrder(CustomerRequirementModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.FileTemplate == null || model.FileTemplate.Length == 0)
                {
                    var toastrOptions = new ToastrOptions()
                    {
                        ProgressBar   = true,
                        PositionClass = ToastPositions.BottomCenter
                    };
                    _toastNotification.AddWarningToastMessage("Please attach a csv file", toastrOptions);
                    return(View());
                }

                //Stream data = null;

                var fileContent = new StreamContent(model.FileTemplate.OpenReadStream())
                {
                    Headers =
                    {
                        ContentLength = model.FileTemplate.Length,
                        ContentType   = new System.Net.Http.Headers.MediaTypeHeaderValue(model.FileTemplate.ContentType)
                    }
                };

                var formDataContent = new MultipartFormDataContent();
                var description     = string.IsNullOrEmpty(model.Description) ? "" : model.Description;
                formDataContent.Add(fileContent, "FileTemplate", model.FileTemplate.FileName);
                formDataContent.Add(new StringContent(model.ShipFromSiteID), "ShipFromSiteID");
                formDataContent.Add(new StringContent(model.ShipToSiteID), "ShipToSiteID");
                formDataContent.Add(new StringContent(model.ShipToLocationID), "ShipToLocationID");
                formDataContent.Add(new StringContent(model.CompleteDeliveryRequestedIndicator.ToString()), "CompleteDeliveryRequestedIndicator");
                formDataContent.Add(new StringContent(model.DeliveryPriorityCode), "DeliveryPriorityCode");
                if (model.RaiseSalesQuote)
                {
                    formDataContent.Add(new StringContent(model.RaiseSalesQuote.ToString()), "RaiseSalesQuote");
                    formDataContent.Add(new StringContent(model.AccountId), "AccountId");
                    formDataContent.Add(new StringContent(model.ExternalReference), "ExternalReference");
                    formDataContent.Add(new StringContent(description), "Description");
                    formDataContent.Add(new StringContent(model.DistributionChannelCode), "DistributionChannelCode");
                    formDataContent.Add(new StringContent(model.PostingDate.Value.ToString()), "PostingDate");
                    formDataContent.Add(new StringContent(model.RequestedDate.Value.ToString()), "RequestedDate");
                    formDataContent.Add(new StringContent(model.SalesUnitId), "SalesUnitId");
                    formDataContent.Add(new StringContent(model.EmployeeResponsible), "EmployeeResponsible");
                }


                var response = await _apiClient.HttpClient.PostAsync("StockTransfer/UploadStockTransfer", formDataContent);

                if (response.IsSuccessStatusCode)
                {
                    var responseData = await response.Content.ReadAsStreamAsync();

                    _toastNotification.AddSuccessToastMessage("Successful!");
                    return(new FileStreamResult(responseData, "text/xml")
                    {
                        FileDownloadName = "response.xml"
                    });
                }
                _toastNotification.AddErrorToastMessage("Failed");
                return(View());
            }
            return(View());
        }