public ActionResult GetMarker(string markerName)
        {
            var repo   = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var marker = repo.GetMarkerCategory(markerName.ToUpper());

            return(Json(new { marker = marker == null ? null : new { marker.Id, marker.Name } }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetValidatoinLists()
        {
            var repo               = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var mats               = repo.GetMaterials();
            var sizes              = repo.GetSizes();
            var markers            = repo.GetMarkerCatergorys();
            var colors             = repo.GetColors().ToList();
            var plannedProductions = repo.GetPlannedProductions().Select(pp =>
            {
                return(new
                {
                    pp.Id,
                    Name = $"{pp.ProductionCatergory.Name} {pp.ProductionCatYear}"
                });
            });

            colors.AddRange(repo.GetColorDetails().Select(c => { return(new Color {
                    Id = c.ColorId, Name = c.Name
                }); }));
            return(Json(new
            {
                material = mats.Select(r => r.Name),
                colors = colors.Select(r => r.Name),
                sizes = sizes.Select(r => { return new { r.Id, r.Name }; }),
                markers = markers.Select(r => r.Name),
                plannedProductions
            }, JsonRequestBehavior.AllowGet));
        }
        //FUNCTIONS

        private int MarkerId(Finalmarker marker)
        {
            var repo  = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var sizes = marker.Sizes.Select(s =>
            {
                return(new MarkerDetail
                {
                    SizeId = s.SizeId,
                    AmountPerLayer = s.AmountPerLayer
                });
            });
            var existingMarker = repo.GetMarker(marker.MarkerCatId, sizes.ToList());

            if (existingMarker != null)
            {
                return(existingMarker.Id);
            }
            else
            {
                var newMarker = new Marker {
                    MarkerCatId = marker.MarkerCatId
                };
                repo.AddMarker(newMarker);
                sizes = sizes.Select(s => { s.MarkerId = newMarker.Id; return(s); });
                repo.AddMarkerDetails(sizes);
                return(newMarker.Id);
            }
        }
        public void DeletePlannedProduction(int plannedProductionId)
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            repo.AddNewUpdateHistory(repo.GetPlannedProduction(plannedProductionId), "deleted");
            repo.DeletePlannedProduction(plannedProductionId);
        }
        // GET: Testing
        public ActionResult Index()
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            var test = repo.GetHistorysOfOneObject(repo.GetReceivingItemsTransaction(124));

            return(View());
        }
Exemple #6
0
        public ActionResult GetColors()
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            return(Json(repo.GetColors().Select(c =>
            {
                return JsonConvert.DeserializeObject <Color>(Helpers.GetBasePropertiesOnDbObject(c));
            }), JsonRequestBehavior.AllowGet));
        }
        public void UpdateMarkerCat(MarkerCategory markerCategory)
        {
            var repo           = new MarkerRespository(Properties.Settings.Default.ManufacturingConStr);
            var prodRepo       = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var originalMarker = repo.GetMarkerCategory(markerCategory.Id);

            prodRepo.AddNewUpdateHistory(originalMarker, markerCategory.Deleted ? "deleted" : null);
            repo.UpdateMarkerCat(originalMarker.SetOrginalDbObjToUpdated(markerCategory));
        }
        public void UpdatePlannedProductionDetails(PlannedProductionDetail plannedProductionDetail)
        {
            var repo        = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var currentItem = repo.GetPlannedProductionDetail(plannedProductionDetail.Id);

            plannedProductionDetail.CreatedOn = currentItem.CreatedOn;
            repo.AddNewUpdateHistory(repo.GetPlannedProductionDetail(plannedProductionDetail.Id));

            repo.UpdatePlannedProductionDetail(plannedProductionDetail);
        }
        //FILE DOWNLOAD

        public void DownloadCuttingInstuctions(int productionId)
        {
            var repo      = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var prod      = repo.GetProductionForExcel(productionId);
            var prodexcel = ExcelActions.ProductionToFormatForExcel(prod);
            var sheet     = ExcelActions.CuttingInstruction(prodexcel);
            var fileName  = prod.Date.ToString("MM.dd");

            FileDownload(sheet, fileName);
        }
Exemple #10
0
        //static string GetSku (Item item)
        //{

        //    var fabric = Fabric(item.FabricId);
        //    var size = Size(item.Size);
        //    var sleave = Sleave(item.Sleeve);
        //    var department = Department(item.DepartmentId);
        //    if(fabric == null || size == null || sleave == null || department == null)
        //    {
        //        return null;
        //    }
        //    return $"{fabric}{item.ColorId.ToString()}{department}{size}{sleave}".ToUpper();
        //}
        //static string Fabric (int fabricId)
        //{
        //    if (fabricId == 2)
        //    {
        //        return "L";
        //    }
        //    else if(fabricId == 1)
        //    {
        //        return "MD";
        //    }
        //    else if(fabricId == 3)
        //    {
        //        return "CT";
        //    }
        //    return null;
        //}
        //static string Department(int departmentId)
        //{
        //    if(departmentId == 1)
        //    {
        //        return "k";
        //    }
        //    else if(departmentId == 2)
        //    {
        //        return "";
        //    }
        //    else if (departmentId == 3)
        //    {
        //        return "b";
        //    }
        //    return null;
        //}
        //static string Size(Sizes size)
        //{
        //    if((int)size == 20)
        //    {
        //        return "b";
        //    }
        //    else if((int)size == 21 || (int)size == 30)
        //    {
        //        return "ess";
        //    }
        //    else if ((int)size == 22 || (int)size == 31 || (int)size == 40)
        //    {
        //        return "es";
        //    }
        //    else if ((int)size == 23 || (int)size == 32 || (int)size == 41)
        //    {
        //        return "s";
        //    }
        //    else if ((int)size == 24 || (int)size == 33 || (int)size == 42)
        //    {
        //        return "m";

        //    }
        //    else if ((int)size == 25 || (int)size == 34 || (int)size == 43)
        //    {
        //        return "l";
        //    }
        //    else if ((int)size == 26 || (int)size == 35 || (int)size == 44)
        //    {
        //        return "el";
        //    }
        //    else if ((int)size == 36)
        //    {
        //        return "x";
        //    }
        //    else if ((int)size == 37)
        //    {
        //        return "xx";
        //    }
        //    else if ((int)size == 38)
        //    {
        //        return "xxx";
        //    }
        //    return null;
        //}
        //static string Sleave (Sleeves sleeves)
        //{
        //    if((int)sleeves == 0)
        //    {
        //        return "";
        //    }
        //    else if((int)sleeves == 1)
        //    {
        //        return "s";
        //    }
        //    else if ((int)sleeves == 2)
        //    {
        //        return "q";
        //    }
        //    else if ((int)sleeves == 3)
        //    {
        //        return "l";
        //    }
        //    return null;
        //}



        static void UpdateComleatedToMarkAsCompleate()
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManuConst);
            var listOfCompleteCTIds = repo.GetClosedInstructionsIds();

            listOfCompleteCTIds.ToList().ForEach(i =>
            {
                repo.MarkCuttingTicketAsCompleate(i);
                Console.WriteLine("sucsses");
            });
            Console.WriteLine("Done");
        }
        public void UpdatePlannedProductionNotes(PlannedProduction plannedProduction)
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            //var currentItem = repo.GetPlannedProduction(plannedProduction.Id).GetObjectBasePropertiesOnDbObject();

            //repo.AddNewUpdateHistory(currentItem);
            //currentItem.Notes = plannedProduction.Notes;
            var currentItem = repo.GetPlannedProduction(plannedProduction.Id);

            repo.AddNewUpdateHistory(currentItem);
            repo.UpdatePlannedProduction(currentItem.SetOrginalDbObjToUpdated(plannedProduction));
        }
        public ActionResult GetLotNumbers()
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            return(Json(repo.GetNotCompleteInstructionForLots().Select(ct => {
                return new
                {
                    id = ct.Id,
                    text = ct.LotNumber
                };
            }), JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetPlannedProductions()
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            return(Json(repo.GetPlannedProductions().Select(pp =>
            {
                return new
                {
                    pp.Id,
                    Name = $"{pp.ProductionCatergory.Name} {pp.ProductionCatYear}"
                };
            }), JsonRequestBehavior.AllowGet));
        }
        //public ActionResult NewMarker()
        //{
        //    var colorRepo = new ColorRepository(Properties.Settings.Default.ConStr);
        //    var repo = new OldCuttingInstructionRepository(Properties.Settings.Default.ConStr);
        //    var vm = new NewMarkerVM
        //    {
        //        Departments = repo.GetDepartments(),
        //        Sleeves = repo.GetAllSleeves(),
        //        Styles = repo.GetAllStyles()
        //    };
        //    return View(vm);
        //}

        //public ActionResult GetSizesOfDepartment(int depId)
        //{
        //    var repo = new OldCuttingInstructionRepository(Properties.Settings.Default.ConStr);
        //    var sizes = repo.GetAllSizesByDepartment(depId);
        //         return Json(sizes.Select(s =>
        //    {
        //        return new
        //        {
        //            Name = s.Name,
        //            Id = s.Id
        //        };
        //    }), JsonRequestBehavior.AllowGet);
        //}

        //public ActionResult NewCuttingInstruction()
        //{
        //    return View();
        //}

        private void UpdateCuttinginstructions(IEnumerable <RecivingItemWithOrdered> recivingItemWithOrdereds)
        {
            var repo     = new ItemRepository(Properties.Settings.Default.ManufacturingConStr);
            var prodRepo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            foreach (var item in recivingItemWithOrdereds)
            {
                var Quantys = repo.GetQuantitysPerItemFromCT(item.ItemId, item.CuttingInstuctionId);
                if (Quantys.AmountOrdered < Quantys.AmountReceived + item.Quantity)
                {
                    prodRepo.UpdateCID(item.OrderedId, Quantys.AmountReceived + item.Quantity);
                }
            }
        }
        public void DeletePlannedProductionDetails(int plannedProductionDetailId)
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var pp   = repo.GetPlannedProductionDetail(plannedProductionDetailId);

            //repo.DeletePlannedProductionDetail(new PlannedProductionDetail
            //{
            //    Id = pp.Id,
            //    ItemId = pp.ItemId,
            //    Quantity = pp.Quantity,
            //    Deleted = true
            //});
            repo.AddNewUpdateHistory(repo.GetPlannedProductionDetail(plannedProductionDetailId), "deleted");
            repo.DeletePlannedProductionDetail(plannedProductionDetailId);
        }
Exemple #16
0
        public ActionResult ItemAdder()
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var vm   = new ItemAdderVM
            {
                Departments        = repo.GetDepartments(),
                Materials          = repo.GetMaterials(),
                Colors             = repo.GetColors(),
                Sleeves            = repo.GetSleeves(),
                Styles             = repo.GetBodyStyles(),
                CheckedDepartments = (List <string>)Session["departments"] ?? null
            };

            return(View(vm));
        }
        public ActionResult GetProductionCats()
        {
            var repo     = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var prodCats = repo.GetProductionCatergories()
                           .Select(pc =>
            {
                return(new
                {
                    pc.Id,
                    pc.Name
                });
            });

            return(Json(prodCats, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetDefaltSizesForAMarkerCat(string markerCatergoryName)
        {
            var repo  = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var sizes = repo.GetDefaltMarkerDetails(markerCatergoryName);

            return(Json(sizes.OrderBy(a => a.SizeId).Select(c =>
            {
                return new
                {
                    c.SizeId,
                    c.Size.Name,
                    c.AmountPerLayer
                };
            }
                                                            ), JsonRequestBehavior.AllowGet));
        }
Exemple #19
0
        private IEnumerable <Item> MakeItemsBasedOnCritera(List <int> departmentIds, List <int> styles, List <int> materialIds, List <int> sleaves, List <int> colorIds)
        {
            var ItemList = new List <Item>();

            foreach (var dep in departmentIds)
            {
                foreach (var style in styles)
                {
                    if (DepartmentRuleChecker(dep, style))
                    {
                        foreach (var material in materialIds)
                        {
                            if (!(material == 1 && dep == 4))
                            {
                                foreach (var sleave in sleaves)
                                {
                                    if (SleeveRuleChecker(dep, sleave))
                                    {
                                        //var sizeList = SizeList(dep, sleave);
                                        var repo     = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
                                        var sizeList = repo.GetAllSizesByDepartment(dep);
                                        sizeList = sleave == 2 ? sizeList.Where(s => s.Id != 10 && s.Id != 11) : sizeList;
                                        foreach (var color in colorIds)
                                        {
                                            foreach (var size in sizeList)
                                            {
                                                ItemList.Add(new Item
                                                {
                                                    DepartmentId = dep,
                                                    BodyStyleId  = style,
                                                    SleeveId     = sleave,
                                                    ColorId      = color,
                                                    SizeId       = size.Id,
                                                    MaterialId   = material
                                                });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(ItemList);
        }
        public ActionResult GetSkusFromWizard(PlanedProductionWizardItem[] items, int MarkerId)
        {
            var repo   = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var marker = repo.GetMarkerCategory(MarkerId);

            if (marker != null)
            {
                var finalItems = items.Select(i =>
                {
                    return(new FinalItem
                    {
                        Item = new Item
                        {
                            ColorId = i.ColorId,
                            SizeId = i.SizeId,
                            MaterialId = i.MaterialId,
                            BodyStyleId = marker.BodyStyleId,
                            SleeveId = marker.SleeveId,
                            DepartmentId = marker.DepartmentId
                        },
                        Quantity = i.Quantity
                    });
                });
                finalItems = finalItems.Select(i =>
                {
                    var item = repo.GetItem(i.Item);
                    if (item != null)
                    {
                        i.Item = item;
                        return(i);
                    }
                    return(null);
                });
                return(Json(finalItems.Where(i => i != null).Select(i =>
                {
                    return new
                    {
                        i.Item.Id,
                        i.Item.SKU,
                        i.Quantity
                    };
                })));
            }
            return(null);
        }
        private int GetFabricId(int matId, int colId)
        {
            var repo   = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var fabric = new Fabric {
                MaterialId = matId, ColorId = colId
            };
            var existingFabric = repo.GetFabric(fabric);

            if (existingFabric != null)
            {
                return(existingFabric.Id);
            }
            else
            {
                repo.AddFabric(fabric);
                return(fabric.Id);
            }
        }
        public void AddRecivedItems(IEnumerable <RecivingItemWithOrdered> items)
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            UpdateCuttinginstructions(items);
            var itemsRecived = items.Where(i => i.Quantity != 0).Select(i =>
            {
                return(new ReceivingItemsTransaction
                {
                    Adjusment = false,
                    ItemId = i.ItemId,
                    CuttingInstuctionId = i.CuttingInstuctionId,
                    Date = i.Date,
                    Quantity = i.Quantity
                });
            });

            repo.AddItemsRecived(itemsRecived);
        }
        public void SubmitPlannedProduction(PlannedProduction plannedProduction, IEnumerable <PlannedProductionDetail> items)
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);

            //if it's a new prdoduction then we add a new one
            if (plannedProduction.Id == 0)
            {
                repo.AddPlannedProduction(plannedProduction);
            }

            items = items.Select(i =>
            {
                i.PlannedProductionId = plannedProduction.Id;
                return(i);
            });
            repo.AddPlannedProductionDetails(items);
            var pc = repo.GetProductionCatergory(plannedProduction.ProductionCatergoryId);

            TempData["Message"] = $"You succsesfully added a new season planned production for {pc.Name} {plannedProduction.ProductionCatYear} <br/>" +
                                  $"With {items.Count()} Items : Total Quantity {items.Sum(i => i.Quantity)}";
        }
        public ActionResult GetCuttingInstructionsWithInfo()
        {
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            //var CuttingInstructions = repo.GetOpenedProductions();
            var CuttingInstructions = repo.GetNonClosedProductions();


            return(Json(CuttingInstructions.Select(p =>
            {
                var sumor = p.CuttingInstructions.Sum(c => c.CuttingInstructionDetails.Sum(pd => pd.CuttingInstructionItems.Sum(d => d.Quantity)));
                var sumre = p.CuttingInstructions.Sum(c => c.ReceivingItemsTransactions.Sum(re => re.Quantity));
                return new
                {
                    Date = p.Date.ToShortDateString(),
                    Lot = string.Join(",", p.CuttingInstructions.Select(c => c.LotNumber)),
                    Id = p.Id,
                    TotalItems = sumor,
                    ItemsNotReceived = sumor - sumre,
                    PercentageFilled = string.Format("{0:P}", double.Parse(sumre.ToString()) / sumor)
                };
            }).OrderByDescending(p => p.Id), JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetAtributteListsForFilter()
        {
            var repo        = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var mats        = repo.GetMaterials();
            var sizes       = repo.GetSizes();
            var markers     = repo.GetMarkerCatergorys();
            var colors      = repo.GetColors().ToList();
            var bodyStyle   = repo.GetBodyStyles();
            var sleeve      = repo.GetSleeves();
            var departments = repo.GetDepartments();

            //colors.AddRange(repo.GetColorDetails().Select(c => { return new Color { Id = c.ColorId, Name = c.Name }; }));
            return(Json(new
            {
                material = mats.Select(r => { return new { r.Id, r.Name, Selected = false }; }),
                colors = colors.Select(r => { return new { r.Id, r.Name, Selected = false }; }),
                sizes = sizes.Select(r => { return new { r.Id, r.Name, Selected = false }; }),
                markers = markers.Select(r => { return new { r.Id, r.Name, Selected = false }; }),
                bodyStyles = bodyStyle.Select(r => { return new { r.Id, r.Name, Selected = false }; }),
                sleeves = sleeve.Select(r => { return new { r.Id, r.Name, Selected = false }; }),
                departments = departments.Select(r => { return new { r.Id, r.Name, Selected = false }; }),
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetDeatilsOfACuttingInstruction(int id)
        {
            var repo    = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var result  = repo.GetProduction(id);
            var details = new List <CutingIntructionDetailsVM>();

            result.CuttingInstructions.ToList().ForEach(c => c.CuttingInstructionDetails.ToList().ForEach(pd =>
            {
                pd.CuttingInstructionItems.ToList().ForEach(pdi =>
                {
                    var received = result.CuttingInstructions.Select(rt => rt.ReceivingItemsTransactions.Where(ri => ri.CuttingInstuctionId == c.Id && ri.ItemId == pdi.ItemId).Sum(ri => ri.Quantity)).Sum();

                    details.Add(new CutingIntructionDetailsVM
                    {
                        Id                   = pdi.ItemId,
                        SKU                  = pdi.Item.SKU,
                        OrderedId            = pdi.Id,
                        Ordered              = pdi.Quantity,
                        Received             = received,
                        PercentageFilled     = string.Format("{0:P}", double.Parse(received.ToString()) / pdi.Quantity),
                        Lot                  = pd.CuttingInstruction.LotNumber,
                        CuttingInstructionId = pd.CuttingInstructionId
                    });
                });
            }));
            return(Json(new
            {
                Production = new
                {
                    Name = $"Production from {result.Date.ToShortDateString()}",
                    Id = result.Id,
                    Date = result.Date.ToShortDateString(),
                    CuttingIntrustionIds = result.CuttingInstructions.Select(c => c.Id)
                },
                details
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetPlannedProduction(PlannedProduction plannedProduction)
        {
            var list = new List <string>();
            var test = list.NotNUllOrEmpty();
            var repo = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var pp   = repo.GetPlannedProductionWithDetails(plannedProduction);

            return(Json(pp != null ? new
            {
                pp.Id,
                pp.ProductionCatergoryId,
                pp.ProductionCatYear,
                Items = pp.PlannedProductionDetails.NotNUllOrEmpty() ? pp.PlannedProductionDetails.Select(p => {
                    return new
                    {
                        p.Id,
                        ItemId = p.Item.Id,
                        p.Item.SKU,
                        p.Quantity,
                        Edit = false
                    };
                }) : null
            } : null));
        }
Exemple #28
0
        public List <BarcodeLable> ConvertProductionIntoBarcodeItems(IEnumerable <CuttingInstructionItem> cuttingInstructionItems, int amountPerSheet)
        {
            var repo           = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var barcodeItems   = RealBarcodes();
            var items          = new List <BarcodeLable>();
            var fabricsWithDis = repo.GetFabicsWithColorDes();

            cuttingInstructionItems.ToList().ForEach(i =>
            {
                var tempItem = barcodeItems.FirstOrDefault(bi => bi.Id == i.ItemId);
                if (tempItem != null)
                {
                    var colordis = fabricsWithDis.FirstOrDefault(f => f.MaterialId == tempItem.MaterialId && f.ColorId == tempItem.ColorId);
                    if (colordis != null)
                    {
                        tempItem.Color = colordis.ColorDescriptionName;
                    }
                    var mod    = i.Quantity % amountPerSheet;
                    var result = mod != 0 ? (i.Quantity - mod) + amountPerSheet : i.Quantity;
                    items.AddRange(Enumerable.Repeat(tempItem, result));
                }
            });
            return(items);
        }
        public static ErrorsAndItems ConvertProductoinToItems(ProductionForCT production)
        {
            var      tempDate = production.Name.Split()[1];
            DateTime date;
            var      isdate = DateTime.TryParseExact(tempDate, DateTimeFormats(), CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out date);

            if (!isdate)
            {
                date = DateTime.Now;
                AddErrorMsg($"Sorry the date {tempDate} is in the wrong format we are going to use the current date instead");
            }
            var repo  = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var items = new List <CuttingInstructionItem>();

            foreach (var marker in production.Markers)
            {
                var markerCat = repo.GetMarkerCategory(marker.Name);
                if (markerCat.NotNull())
                {
                    var sizes = marker.Sizes;
                    foreach (var s in sizes)
                    {
                        foreach (var colmat in marker.ColorMaterials)
                        {
                            var colorId = repo.GetColorId(colmat.Color);
                            if (!NotNull(colorId))
                            {
                                colorId = repo.GetColorDetailsId(colmat.Color);
                            }
                            if (NotNull(colorId))
                            {
                                var mat = repo.GetMaterialId(colmat.Material);
                                if (NotNull(mat))
                                {
                                    var item = new Item
                                    {
                                        DepartmentId = markerCat.DepartmentId,
                                        BodyStyleId  = markerCat.BodyStyleId,
                                        SleeveId     = markerCat.SleeveId,
                                        ColorId      = (int)colorId,
                                        MaterialId   = (int)mat,
                                        SizeId       = s.SizeId
                                    };
                                    var dbItem = repo.GetItem(item);
                                    if (NotNull(dbItem))
                                    {
                                        var itemQuantity = colmat.Layers * s.AmountPerLayer;
                                        if (itemQuantity > 0)
                                        {
                                            items.Add(new CuttingInstructionItem
                                            {
                                                ItemId   = dbItem.Id,
                                                Item     = dbItem,
                                                Quantity = itemQuantity
                                            });
                                        }
                                    }
                                    else
                                    {
                                        var size       = repo.GetSize(item.SizeId).Name;
                                        var material   = repo.GetMaterial(item.MaterialId).Name;
                                        var color      = repo.GetColor(item.ColorId).Name;
                                        var department = repo.GetDepartment(item.DepartmentId).Name;
                                        var bodyStyle  = repo.GetBodyStyle(item.BodyStyleId).Name;
                                        var sleeve     = repo.GetSleeve(item.SleeveId).Name;
                                        AddErrorMsg("item", $"with size:{size}, Material:{material},Color:{color},Department:{department},BodyStyle:{bodyStyle}, Sleeve:{sleeve}");
                                    }
                                }
                                else
                                {
                                    AddErrorMsg("materieal", colmat.Material);
                                }
                            }
                            else
                            {
                                AddErrorMsg("Color", colmat.Color);
                            }
                        }
                    }
                }
                else
                {
                    AddErrorMsg("marker", marker.Name);
                }
            }
            var returnItem = new ErrorsAndItems
            {
                Items  = items,
                Errors = _erros,
                Date   = date
            };

            _erros = new List <string>();
            return(returnItem);
        }
        private static List <SizeWithLayer> NewMarkerSizeConcact(string[] split)
        {
            var repo           = new ProductionRespository(Properties.Settings.Default.ManufacturingConStr);
            var marker         = repo.GetMarkerCategory(split[0]);
            var sizeFromMarker = new List <SizeWithLayer>();

            if (marker != null)
            {
                if (split.Count() > 2 && int.TryParse(split[2], out int amountInt))
                {
                    sizeFromMarker = repo.GetDefaltMarkerDetails(marker.Id).Select(md =>
                    {
                        return(new SizeWithLayer {
                            SizeId = md.SizeId, Name = md.Size.Name
                        });
                    }).ToList();
                }
            }
            else
            {
                AddErrorMsg("marker", split[0]);
            }
            for (int z = 2; z < split.Count(); z++)
            {
                if (split[1].Split('_').Count() > 1)
                {
                    AddErrorMsg($"Sorry [ {String.Join("-", split)} ] is the wrong format! {Environment.NewLine} Check if there is [-] bettween [new marker] and first size");
                    break;
                }
                if (int.TryParse(split[z], out int amountInt))
                {
                    if (split.Count() - 2 != sizeFromMarker.Count)
                    {
                        AddErrorMsg($"Sorry [ {String.Join("-", split)} ] does not contain all the sizes. There is [ {sizeFromMarker.Count} ] sizes for marker [ {split[0]} ]! {Environment.NewLine} Check if there is a [-] bettween [new marker] and first size");
                        break;
                    }
                    sizeFromMarker[z - 2].AmountPerLayer = amountInt;
                }
                else
                {
                    var tempSplit = split[z].Split('_');
                    if (tempSplit.Count() > 1)
                    {
                        var tempSize   = tempSplit[0];
                        var tempAmount = tempSplit[1];
                        var SizeIs     = repo.GetSize(tempSize);
                        if (NotNull(SizeIs) && int.TryParse(tempAmount, out int amountI))
                        {
                            sizeFromMarker.Add(new SizeWithLayer {
                                SizeId = SizeIs.Id, Name = SizeIs.Name, AmountPerLayer = amountI
                            });
                        }
                        else
                        {
                            AddErrorMsg("size", tempSize);
                        }
                    }
                    else
                    {
                        AddErrorMsg($"Sorry [{split[z]}] is not a number! Please change the format!");
                        break;
                    }
                }
            }
            return(sizeFromMarker.Where(s => s.AmountPerLayer != 0).ToList());
        }