public async Task <IActionResult> Index(DateTime?startDate, DateTime?finishDate) { int startDateUnix = UnixTimeConverter.ConvertToUnixTimestamp(startDate ?? DateTime.Parse("01.01.1970")); int finishDateUnix = UnixTimeConverter.ConvertToUnixTimestamp(finishDate ?? DateTime.Now); ViewBag.StartDate = (startDate ?? DateTime.Parse("01.01.1970")).ToShortDateString(); ViewBag.FinishDate = (finishDate ?? DateTime.Now).ToShortDateString(); List <Groupnom> groupnoms = await _context.Groupnom .Where(b => !b.Deleted) .OrderBy(b => b.Name) .IncludeFilter(b => b.Nomencl .Where(c => !c.Deleted && c.Shipdoc .Any(d => d.Nomenclid == c.Id && d.Shipment.Suppdate >= startDateUnix && d.Shipment.Suppdate <= finishDateUnix))) .ToListAsync(); ViewBag.Supplyer = await _context.Supplyer .Where(b => !b.Deleted) .IncludeFilter(b => b.Shipment.Where(c => !c.Deleted && c.Suppdate >= startDateUnix && c.Suppdate <= finishDateUnix)) .Include(b => b.Shipment) .ThenInclude(c => c.Shipdocs) .ToListAsync(); ViewBag.Shipdocs = await _context.Shipdoc .Include(b => b.Shipment) .Where(b => !b.Shipment.Deleted && startDateUnix <= b.Shipment.Suppdate && finishDateUnix >= b.Shipment.Suppdate) .OrderBy(b => b.Shipment.Suppdate) .ThenBy(c => c.Nomenclid) .ToListAsync(); return(View(groupnoms)); }
public async Task <IActionResult> Create([Bind("Supplyerid")] Shipment shipment) { if (ModelState.IsValid) { shipment.Suppdate = UnixTimeConverter.ConvertToUnixTimestamp(DateTime.Now.Date); shipment.Deleted = false; _context.Add(shipment); await _context.SaveChangesAsync(); return(RedirectToAction("Create", "Shipdocs", new { shipmentid = shipment.Id })); } ViewData["Supplyerid"] = new SelectList(_context.Supplyer.Where(b => !b.Deleted), "Id", "Name", shipment.Supplyerid); return(View(shipment)); }