public ActionResult Delete(TransportRequisitionWithTransporter requisitionWithTransporter)
        {
            var selectedTransRequision = requisitionWithTransporter.TransReqwithOutTransporters.Where(m => m.Selected == true);
            try
            {
                foreach (var transportRequisitionWithoutWinnerModel in selectedTransRequision)
                {
                    _transReqWithoutTransporterService.DeleteById(
                        transportRequisitionWithoutWinnerModel.TransReqWithoutTransporterID);
                    _transReqWithoutTransporterService.Save();

                }

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                var log = new Logger();
                log.LogAllErrorsMesseges(ex, _log);
                ModelState.AddModelError("Errors", @"Unable to delete the requisition");
            }

            return RedirectToAction("Index");
        }
        public ActionResult AssignTransporter(TransportRequisitionWithTransporter requisitionWithTransporter)
        {
            var selectedTransRequision = requisitionWithTransporter.TransReqwithOutTransporters.Where(m => m.Selected == true);
            try
            {
                _transportOrderService.ReAssignTransporter(selectedTransRequision, requisitionWithTransporter.SelectedTransporterID);
                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                var log = new Logger();
                log.LogAllErrorsMesseges(ex, _log);
                ModelState.AddModelError("Errors", "Unable to create transport order");
            }

            return RedirectToAction("Index");
        }
 public TransportRequisitionWithTransporter GetRequisitionsWithoutTransporter()
 {
     var req = new TransportRequisitionWithTransporter();
     //req.Transporters = _transportOrderService.GetTransporter();
     var transReqWithoutTransport = _transReqWithoutTransporterService.FindBy(m => m.IsAssigned == false);
     if (transReqWithoutTransport != null)
     {
         req.TransReqwithOutTransporters = GetTransReqWithoutTransporter(transReqWithoutTransport).ToList();
     }
     return req;
 }
        public TransportRequisitionWithTransporter GetRequisitionsWithoutTransporter(int woredaId, int transReqId)
        {
            var req = new TransportRequisitionWithTransporter();

            var transReqDetail = _transportRequisitionService.FindBy(f => f.TransportRequisitionID == transReqId).SelectMany(d => d.TransportRequisitionDetails);

            var reliefRequisitionDetail = transReqDetail.SelectMany(detail => detail.ReliefRequisition.ReliefRequisitionDetails).ToList();
            var filteredTrans = reliefRequisitionDetail.Where(d => d.FDP.AdminUnit.AdminUnitID == woredaId).Select(s => s.RequisitionDetailID).ToList();

            var x = _transReqWithoutTransporterService.FindBy(m => filteredTrans.Contains(m.RequisitionDetailID) && m.IsAssigned == false);// &&
            //  m.ReliefRequisitionDetail != null && (m.IsAssigned == false)).OrderByDescending(t => t.TransportRequisitionDetailID));
            //}
            //var transReqWithoutTransport = _transReqWithoutTransporterService.Get(m => m.ReliefRequisitionDetail != null && (m.IsAssigned == false && m.ReliefRequisitionDetail.FDP.AdminUnit.AdminUnitID == woredaId && m.TransportRequisitionDetail.TransportRequisition.TransportRequisitionID == transReqId)).Distinct().OrderByDescending(t => t.TransportRequisitionDetailID);
            req.TransReqwithOutTransporters = GetTransReqWithoutTransporter(x).ToList();
            return req;
        }
        public TransportRequisitionWithTransporter GetRequisitionsWithoutTransporter(int woredaId)
        {
            var req = new TransportRequisitionWithTransporter();

            var transReqWithoutTransport = _transReqWithoutTransporterService.FindBy(m => m.ReliefRequisitionDetail != null && (m.IsAssigned == false && m.ReliefRequisitionDetail.FDP.AdminUnit.AdminUnitID == woredaId)).OrderByDescending(t => t.TransportRequisitionDetailID);
            if (transReqWithoutTransport != null)
            {
                req.TransReqwithOutTransporters = GetTransReqWithoutTransporter(transReqWithoutTransport).ToList();
            }
            return req;
        }