public async Task <IActionResult> Edit(int id, [Bind("Busena")] Shipment shipment) { var oldShipment = _context.Shipments.Include(x => x.driver).FirstOrDefault(x => x.ShipmentId == id); if (oldShipment != null) { try { oldShipment.driver.MasinosBusena = (CarStatus)shipment.Busena; if (oldShipment.driver.MasinosBusena == CarStatus.Arrived) { oldShipment.driver.AtvykimoLaikas = DateTime.Now; } if (oldShipment.driver.MasinosBusena == CarStatus.Left) { oldShipment.driver.IsvykimoLaikas = DateTime.Now; } _context.Update(oldShipment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShipmentExists(shipment.ShipmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(shipment)); }
public async Task <IActionResult> Edit(int id, [Bind("GateId,Vieta")] Gate gate, [Bind("TransportType")] int transportType, [Bind("WareHouse")] int wareHouse) { gate.GateId = id; if (ModelState.IsValid) { try { gate.WareHouse = _context.WareHouse.Where(x => x.WareHouseId == wareHouse).FirstOrDefault(); gate.TransportType = new List <GateTransportType>(); gate.TransportType.Add(new GateTransportType { PriimamoMasinosTipas = (CarType)transportType }); _context.Update(gate); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GateExists(gate.GateId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gate)); }
public async Task <IActionResult> RegisterArrival(int id, int gateTimeId) { var oldShipment = _context.Shipments.Include(x => x.driver).FirstOrDefault(x => x.ShipmentId == id); if (oldShipment != null) { try { oldShipment.gateTime = _context.GateTime.FirstOrDefault(x => x.GateTimeId == gateTimeId); oldShipment.gateTime.IsUsed = true; _context.Update(oldShipment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } } return(RedirectToAction(nameof(RegisterArrival))); }