// GET: BoatOwnerReciepts/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var boatOwnerReciept = await _context.BoatOwnerReciepts
                                   .Include(b => b.Boat)
                                   .Include(b => b.Sarha)
                                   .FirstOrDefaultAsync(m => m.BoatOwnerRecieptID == id);

            if (boatOwnerReciept == null)
            {
                return(NotFound());
            }
            ViewBag.Items = _context.BoatOwnerItems.Where(i => i.BoatOwnerRecieptID == id).Include(x => x.Fish).Include(x => x.ProductionType);

            DistributionVm model = new DistributionVm();

            model.BoatOwnerReciept     = boatOwnerReciept;
            model.NormalboatOwnerItems = _context.BoatOwnerItems.Include(c => c.Fish).Include(c => c.ProductionType).Where(c => c.BoatOwnerRecieptID == boatOwnerReciept.BoatOwnerRecieptID && c.AmountId == null).ToList();
            model.AmountboatOwnerItems = _context.BoatOwnerItems.Include(c => c.Fish).Include(c => c.ProductionType).Where(c => c.BoatOwnerRecieptID == boatOwnerReciept.BoatOwnerRecieptID && c.AmountId != null).ToList();

            var results = from p in model.AmountboatOwnerItems
                          group p.BoatOwnerItemID by p.AmountId into g
                          select new AmountVm {
                AmountId = g.Key, items = g
            };

            model.Amounts = results;
            return(View(model));
        }
        public IActionResult Distribute(int id)
        {
            var rec = _context.BoatOwnerReciepts.Include(c => c.Boat).Where(c => c.BoatOwnerRecieptID == id).FirstOrDefault();

            ViewBag.Merchants = new SelectList(_context.Merchants.Where(c => c.IsFromOutsideCity == false).ToList(), "MerchantID", "MerchantName");

            DistributionVm model = new DistributionVm();

            model.BoatOwnerReciept     = rec;
            model.NormalboatOwnerItems = _context.BoatOwnerItems.Include(c => c.Fish).Include(c => c.ProductionType).Where(c => c.BoatOwnerRecieptID == rec.BoatOwnerRecieptID && c.AmountId == null).ToList();
            model.AmountboatOwnerItems = _context.BoatOwnerItems.Include(c => c.Fish).Include(c => c.ProductionType).Where(c => c.BoatOwnerRecieptID == rec.BoatOwnerRecieptID && c.AmountId != null).ToList();

            var results = from p in model.AmountboatOwnerItems
                          group p.BoatOwnerItemID by p.AmountId into g
                          select new AmountVm {
                AmountId = g.Key, items = g
            };

            model.Amounts = results;

            return(View(model));
        }