public GarmentProductViewModel MapToViewModel(GarmentProduct garmentProduct)
        {
            GarmentProductViewModel garmentProductVM = new GarmentProductViewModel
            {
                Id                 = garmentProduct.Id,
                UId                = garmentProduct.UId,
                _IsDeleted         = garmentProduct._IsDeleted,
                Active             = garmentProduct.Active,
                _CreatedUtc        = garmentProduct._CreatedUtc,
                _CreatedBy         = garmentProduct._CreatedBy,
                _CreatedAgent      = garmentProduct._CreatedAgent,
                _LastModifiedUtc   = garmentProduct._LastModifiedUtc,
                _LastModifiedBy    = garmentProduct._LastModifiedBy,
                _LastModifiedAgent = garmentProduct._LastModifiedAgent,
                Code               = garmentProduct.Code,
                Name               = garmentProduct.Name,

                UOM = new GarmentProductUomViewModel
                {
                    Id   = garmentProduct.UomId,
                    Unit = garmentProduct.UomUnit
                },
                Tags        = garmentProduct.Tags,
                Const       = garmentProduct.Const,
                Yarn        = garmentProduct.Yarn,
                Width       = garmentProduct.Width,
                Remark      = garmentProduct.Remark,
                ProductType = garmentProduct.ProductType,
                Composition = garmentProduct.Composition
            };

            return(garmentProductVM);
        }
        public GarmentProduct MapToModel(GarmentProductViewModel garmentProductVM)
        {
            GarmentProduct garmentProduct = new GarmentProduct
            {
                Id                 = garmentProductVM.Id,
                _IsDeleted         = garmentProductVM._IsDeleted,
                Active             = garmentProductVM.Active,
                _CreatedUtc        = garmentProductVM._CreatedUtc,
                _CreatedBy         = garmentProductVM._CreatedBy,
                _CreatedAgent      = garmentProductVM._CreatedAgent,
                _LastModifiedUtc   = garmentProductVM._LastModifiedUtc,
                _LastModifiedBy    = garmentProductVM._LastModifiedBy,
                _LastModifiedAgent = garmentProductVM._LastModifiedAgent,
                Code               = garmentProductVM.Code,
                Name               = garmentProductVM.Name,
                Tags               = garmentProductVM.Tags,
                Const              = garmentProductVM.Const,
                Yarn               = garmentProductVM.Yarn,
                Width              = garmentProductVM.Width,
                Remark             = garmentProductVM.Remark,
                ProductType        = garmentProductVM.ProductType,
                Composition        = garmentProductVM.Composition
            };

            garmentProduct.UomId   = null;
            garmentProduct.UomUnit = null;
            if (!Equals(garmentProductVM.UOM, null))
            {
                garmentProduct.UomId   = garmentProductVM.UOM.Id;
                garmentProduct.UomUnit = garmentProductVM.UOM.Unit;
            }


            return(garmentProduct);
        }
        public async Task Post()
        {
            GarmentProductViewModel garmentProductViewModel = GenerateTestModel();
            var response = await this.Client.PostAsync(URI, new StringContent(JsonConvert.SerializeObject(garmentProductViewModel).ToString(), Encoding.UTF8, "application/json"));

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
        }
        public GarmentProductViewModel GetProductFromCore(string productId)
        {
            var httpService            = (IHttpService)ServiceProvider.GetService(typeof(IHttpService));
            var responseGarmentProduct = httpService.GetAsync($"{GarmentCoreProductUri}/" + productId).Result.Content.ReadAsStringAsync();

            Dictionary <string, object> resultGarmentProduct = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseGarmentProduct.Result);
            GarmentProductViewModel     viewModel            = JsonConvert.DeserializeObject <GarmentProductViewModel>(resultGarmentProduct.GetValueOrDefault("data").ToString());

            return(viewModel);
        }
        public GarmentProductViewModel GetNewData()
        {
            long nowTicks = DateTimeOffset.Now.Ticks;

            var data = new GarmentProductViewModel
            {
            };

            return(data);
        }
        public IActionResult Get(int id)
        {
            try
            {
                var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");

                GarmentExternalPurchaseOrder          model     = facade.ReadById(id);
                GarmentExternalPurchaseOrderViewModel viewModel = mapper.Map <GarmentExternalPurchaseOrderViewModel>(model);
                if (viewModel == null)
                {
                    throw new Exception("Invalid Id");
                }
                if (indexAcceptPdf < 0)
                {
                    viewModel.IsUnpost = facade.GetIsUnpost(id);
                    return(Ok(new
                    {
                        apiVersion = ApiVersion,
                        statusCode = General.OK_STATUS_CODE,
                        message = General.OK_MESSAGE,
                        data = viewModel,
                    }));
                }
                else
                {
                    int clientTimeZoneOffset   = int.Parse(Request.Headers["x-timezone-offset"].First());
                    SupplierViewModel supplier = facade.GetSupplier(viewModel.Supplier.Id);

                    viewModel.Supplier = supplier == null? viewModel.Supplier : supplier;
                    foreach (var item in viewModel.Items)
                    {
                        GarmentInternalPurchaseOrder ipo = IPOfacade.ReadById(item.POId);
                        item.ShipmentDate = ipo == null ? item.ShipmentDate : ipo.ShipmentDate;
                        GarmentProductViewModel product = facade.GetProduct(item.Product.Id);
                        item.Product = product == null ? item.Product : product;
                    }

                    GarmentExternalPurchaseOrderPDFTemplate PdfTemplateLocal = new GarmentExternalPurchaseOrderPDFTemplate();
                    MemoryStream stream = PdfTemplateLocal.GeneratePdfTemplate(viewModel, clientTimeZoneOffset);

                    return(new FileStreamResult(stream, "application/pdf")
                    {
                        FileDownloadName = $"{viewModel.EPONo}.pdf"
                    });
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public GarmentProductViewModel GetEmptyData()
        {
            GarmentProductViewModel Data = new GarmentProductViewModel();

            Data.Name     = "";
            Data.Code     = "";
            Data.UOM.Id   = 1;
            Data.UOM.Unit = "";

            return(Data);
        }
        public GarmentProductViewModel GetNewDataBP()
        {
            long nowTicks = DateTimeOffset.Now.Ticks;

            var data = new GarmentProductViewModel
            {
                Code = "CodeTestBP123",
                Name = "Name123BP",
            };

            return(data);
        }
示例#9
0
        public void Should_Error_Upload_CSV_Data_with_false_UOM()
        {
            GarmentProductViewModel Vmodel1 = DataUtil.GetNewData4();
            GarmentProductViewModel Vmodel2 = DataUtil.GetNewData4();
            GarmentProductViewModel Vmodel3 = DataUtil.GetNewData5();
            GarmentProductViewModel Vmodel4 = DataUtil.GetNewData5();
            var Response = Services.UploadValidate(new List <GarmentProductViewModel> {
                Vmodel1, Vmodel2, Vmodel3, Vmodel4
            }, null);

            Assert.Equal(Response.Item1, false);
        }
        public GarmentProductViewModel GetNewData()
        {
            long nowTicks = DateTimeOffset.Now.Ticks;

            var data = new GarmentProductViewModel
            {
                Code        = "CodeTest123",
                Name        = "Name123",
                ProductType = "FABRIC"
            };

            return(data);
        }
示例#11
0
        public GarmentProductViewModel GetNewData2()
        {
            long nowTicks = DateTimeOffset.Now.Ticks;

            var data = new GarmentProductViewModel
            {
                Code        = "CodeTest123",
                Name        = "Name123",
                Const       = "Const",
                Composition = "Compost",
                Width       = "12",
                Yarn        = "yarn"
            };

            return(data);
        }
        public List <GarmentProductViewModel> getProductForPDF(GarmentLeftoverWarehouseExpenditureFabric model)
        {
            List <GarmentProductViewModel> garmentProducts = new List <GarmentProductViewModel>();

            foreach (var item in model.Items)
            {
                GarmentProductViewModel garmentProduct = new GarmentProductViewModel();
                var stock = DbContext.GarmentLeftoverWarehouseStocks.Where(a => a.PONo == item.PONo).FirstOrDefault();
                if (stock != null)
                {
                    garmentProduct      = GetProductFromCore(stock.ProductId.ToString());
                    garmentProduct.PONo = item.PONo;
                    garmentProducts.Add(garmentProduct);
                }
            }
            return(garmentProducts);
        }
示例#13
0
        public GarmentProductViewModel GetProduct(long productId)
        {
            string             productUri = "master/garmentProducts";
            IHttpClientService httpClient = (IHttpClientService)this.serviceProvider.GetService(typeof(IHttpClientService));

            if (httpClient != null)
            {
                var response = httpClient.GetAsync($"{APIEndpoint.Core}{productUri}/{productId}").Result.Content.ReadAsStringAsync();
                Dictionary <string, object> result    = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Result);
                GarmentProductViewModel     viewModel = JsonConvert.DeserializeObject <GarmentProductViewModel>(result.GetValueOrDefault("data").ToString());
                return(viewModel);
            }
            else
            {
                GarmentProductViewModel viewModel = null;
                return(viewModel);
            }
        }
        public GarmentProductViewModel GetNewData4()
        {
            string guid = Guid.NewGuid().ToString();
            GarmentProductViewModel TestData = new GarmentProductViewModel
            {
                Code   = string.Format("TEST {0}", guid),
                Name   = "test",
                Active = true,
                UOM    = new GarmentProductUomViewModel
                {
                    Id   = 42,
                    Unit = "YARD"
                },
                ProductType = "FABRIC",
                Composition = string.Format("TEST {0}", guid),
                Const       = string.Format("TEST {0}", guid),
                Yarn        = string.Format("TEST {0}", guid),
                Width       = string.Format("TEST {0}", guid),
                UId         = guid
            };

            return(TestData);
        }