Exemple #1
0
        public GetLongIdResponse  DoesMaterialNameExist(string materialName)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesMaterialNameExist(materialName);
            return(response);
        }
Exemple #2
0
        public GetLongIdResponse DoesFoliageExist(FoliageDTO foliage)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesFoliageExist(foliage);
            return(response);
        }
Exemple #3
0
        public GetLongIdResponse ImportFoliage(ImportFoliageRequest request)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.ImportFoliage(request);
            return(response);
        }
Exemple #4
0
        public GetLongIdResponse DoesPlantExist(PlantDTO plantDTO)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesPlantExist(plantDTO);
            return(response);
        }
Exemple #5
0
        public GetLongIdResponse ImportImage(AddImageRequest request)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.AddPlantImage(request.imgBytes);
            return(response);
        }
Exemple #6
0
        public GetLongIdResponse ServiceCodeIsNotUnique(string serviceCode)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.ServiceCodeIsNotUnique(serviceCode);
            return(response);
        }
Exemple #7
0
        public GetLongIdResponse DoesPlantTypeExist(string plantType)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesPlantTypeExist(plantType);
            return(response);
        }
Exemple #8
0
        public GetLongIdResponse ImportContainer(ImportContainerRequest request)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.ImportContainer(request);
            return(response);
        }
Exemple #9
0
        public GetLongIdResponse DoesServiceCodeExist(ServiceCodeDTO serviceCodeDTO)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesServiceCodeExist(serviceCodeDTO);
            return(response);
        }
Exemple #10
0
        public GetLongIdResponse DoesContainerExist(ContainerDTO container)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesContainerExist(container);
            return(response);
        }
Exemple #11
0
        public GetLongIdResponse DoesContainerNameExist(string containerName)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesContainerNameExist(containerName);
            return(response);
        }
Exemple #12
0
        public GetLongIdResponse ImportMaterial(ImportMaterialRequest request)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.ImportMaterial(request);
            return(response);
        }
Exemple #13
0
        public GetLongIdResponse DoesMaterialExist(MaterialDTO material)
        {
            GetLongIdResponse response = new GetLongIdResponse();

            response.returnedId = inventoryManager.DoesMaterialExist(material);
            return(response);
        }
        private long ImportImage(string fileName)
        {
            long newImageId = 0;

            try
            {
                byte[]       ImageData;
                FileStream   fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);
                ImageData = br.ReadBytes((int)fs.Length);
                br.Close();
                fs.Close();

                AddImageRequest request = new AddImageRequest();
                request.imgBytes = ImageData;
                string        jsonData = JsonConvert.SerializeObject(request);
                StringContent content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

                string result = Post("ImportImage", content);

                GetLongIdResponse r = JsonConvert.DeserializeObject <GetLongIdResponse>(result);
                newImageId = r.returnedId;
            }
            catch (Exception ex)
            {
            }

            return(newImageId);
        }
        private void ImportMaterial(KeyValuePair <int, List <ExcelRowData> > kvp, ExcelPicture img)
        {
            //check for presence of plantName - add if not present
            long materialNameId = 0;

            int column = columnIndicesAndNames.Where(a => a.Value == "NAME").Select(b => b.Key).First();

            string materialName = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            string result = Get("DoesMaterialNameExist", "materialName=" + materialName);

            GetLongIdResponse r = JsonConvert.DeserializeObject <GetLongIdResponse>(result);

            materialNameId = r.returnedId;

            column = columnIndicesAndNames.Where(a => a.Value == "SIZE").Select(b => b.Key).First();

            string materialSize = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            //check for presence of plantType - add if not present

            long materialTypeId = 0;

            column = columnIndicesAndNames.Where(a => a.Value == "TYPE").Select(b => b.Key).First();

            string materialType = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            result = Get("DoesMaterialTypeExist", "materialType=" + materialType);

            r = JsonConvert.DeserializeObject <GetLongIdResponse>(result);
            materialTypeId = r.returnedId;

            ////using cost, retail, plantName and plant Type, check for presence of service code - add if not present

            //ServiceCodeDTO serviceCode = GetServiceCodeDTO(kvp);

            //string jsonData = JsonConvert.SerializeObject(serviceCode);
            //var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

            //result = Post("DoesServiceCodeExist", content);

            long serviceCodeId = 0;

            column = columnIndicesAndNames.Where(a => a.Value == "CODE").Select(b => b.Key).First();

            string serviceCode = rowData[kvp.Key].Where(a => a.column == column).Select(b => b.data).FirstOrDefault() as string;

            result = Get("ServiceCodeIsNotUnique", "serviceCode=" + serviceCode);
            r      = JsonConvert.DeserializeObject <GetLongIdResponse>(result);

            serviceCodeId = r.returnedId;

            //check for presence of plant - add if not present

            long materialId = 0;

            MaterialDTO materialDTO = GetMaterialDTO(kvp);

            string        jsonData = JsonConvert.SerializeObject(materialDTO);
            StringContent content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            result = Post("DoesMaterialExist", content);
            r      = JsonConvert.DeserializeObject <GetLongIdResponse>(result);

            materialId = r.returnedId;

            //check for presence of inventory - add if not present

            ImportMaterialRequest request = new ImportMaterialRequest();

            //add image if present
            if (img != null)
            {
                ImageConverter imgCon = new ImageConverter();
                request.imageBytes = (byte[])imgCon.ConvertTo(img.Image, typeof(byte[]));
            }

            //create DTO - send to service - backend will do the hookup

            request.MaterialSize = materialSize;
            request.AddMaterialRequest.Material.MaterialSize = materialSize;

            if (materialNameId == 0)
            {
                request.MaterialName = materialName;
            }
            else
            {
                request.AddMaterialRequest.Material.MaterialNameId = materialNameId;
            }

            if (materialTypeId == 0)
            {
                request.MaterialType = materialType;
            }
            else
            {
                request.AddMaterialRequest.Material.MaterialTypeId = materialTypeId;
            }


            request.ServiceCode = GetServiceCodeDTO(kvp);

            if (serviceCodeId > 0)
            {
                ServiceCodeDTO original = GetServiceCodeById(serviceCodeId);
                UpdateServiceCode(original, request.ServiceCode);
                request.ServiceCode = original;
                request.ServiceCode.ServiceCodeId = serviceCodeId;
                request.AddMaterialRequest.Inventory.ServiceCodeId = serviceCodeId;
            }

            jsonData = JsonConvert.SerializeObject(request);
            content  = new StringContent(jsonData, Encoding.UTF8, "application/json");

            Post("ImportMaterial", content);
        }