public void RenderDetailofPart()
        {
            using (var context = new ForwardingAppContext())
            {
                var query = (from order in context.Set <Order>()
                             join box in context.Set <Box>()
                             on order.BoxId equals box.BoxId
                             select new { order, box }).OrderBy(w => w.order.Weight);

                int  mod = 0;
                Part p;

                var PartList = context.Parts.ToList();
                //Her parçaya ait ağırlıklar ve maliyetleri hesaplandi ve tabloya yazildi
                foreach (var item in query)
                {
                    if (PartList.Where(b => b.BoxId == item.box.BoxId).FirstOrDefault() == null)
                    {
                        mod = item.order.Weight % item.box.PartCount;//mod parca agirligi hesaplamasi icin
                        for (int i = 1; i <= item.box.PartCount; i++)
                        {
                            p            = new Part();
                            p.PartNumber = i;
                            p.BoxId      = item.box.BoxId;

                            if (mod == 0)
                            {
                                p.PartWeight = item.order.Weight / item.box.PartCount;
                            }
                            else
                            {
                                p.PartWeight = item.order.Weight / item.box.PartCount;
                                if (i == item.box.PartCount)
                                {
                                    p.PartWeight = (item.order.Weight / item.box.PartCount) + 1;
                                }
                            }
                            p.PartCost = 50 + (p.PartWeight * 7); //maliyet hesaplama
                            context.Parts.Add(p);
                        }
                    }
                }
                context.SaveChanges();
            }
        }
        public void RenderPartCountofBox()
        {
            using (var context = new ForwardingAppContext())
            {
                //Paketler agirliklarina göre kücükten büyüge siralandi
                var sortingOrder = context.Orders.OrderBy(s => s.Weight);

                var BoxList = context.Boxes.ToList();
                //Her paketin parça sayısını belirlendi ve ilgili tabloya yazildi
                foreach (var item in sortingOrder.ToList())
                {
                    if (BoxList.Where(b => b.BoxId == item.BoxId).FirstOrDefault() == null)
                    {
                        Box bx = new Box();
                        bx.BoxId     = item.BoxId;
                        bx.PartCount = _minPartCount;
                        context.Boxes.Add(bx);
                        _minPartCount++;
                    }
                }

                context.SaveChanges();
            }
        }