public ActionResult Manager() { ShipmentSearch model = new ShipmentSearch { WarehouseId = -1, Keyword = "", ToTime = DateTime.Now.ToUnixTimestamp(), FromTime = DateTime.Now.AddDays(-30).ToUnixTimestamp() }; List <ShipmentViewDTO> lsShipment = _shipmentService.Admin_SearchShipment(model); ListShipmentModels lsResult = new ListShipmentModels() { FromDate = DateTime.Now.AddDays(-30), ToDate = DateTime.Now }; if (lsShipment != null && lsShipment.Any()) { var todate = DateTime.Now; var fromdate = DateTime.Now.AddDays(-30);//lsShipment.Min(x => x.CreateTime).UnixTimeStampToDateTime(); var result = GetPositionWithModel(lsShipment, fromdate, todate); lsResult = new ListShipmentModels() { ListResult = result, FromDate = fromdate, ToDate = todate }; } return(View(lsResult)); }
public async Task <ShipmentList> Execute(ShipmentSearch search) { try { // TODO valdiate search object return(await ShipmentDAO.Methods.Search(search)); } catch (Exception) { throw; } }
public ActionResult SearchShipment(ShipmentSearch model) { CustomJsonResult result = new CustomJsonResult(); if (model.ToTime == 0) { model.ToTime = DateTime.Now.ToUnixTimestamp(); } result.Result = _shipmentService.Admin_SearchShipment(model); //result.Optional = model.Total; return(Json(result)); }
public async Task <IActionResult> SearchShipments(ShipmentSearch search) { try { var req = GrpcShipmentSearchRequestFactory.GetFrom(search); var resp = await ShippingClient.SearchShipments(req); return(new ContentResult() { Content = ShipmentListPresenter.GetSerializedFrom(resp), ContentType = "application/json" }); } catch (Exception e) { throw; } }
public GrpcShipmentSearchRequestFactory(ShipmentSearch search) => Search = search;
public static GrpcShipmentSearchRequest GetFrom(ShipmentSearch search) => new GrpcShipmentSearchRequestFactory(search).Get();
public Search(ShipmentSearch request) { Request = request; SetFilter(); SetSorting(); }
public List <ShipmentViewDTO> Admin_SearchShipment(ShipmentSearch model = null) { if (model == null) { model = new ShipmentSearch { WarehouseId = -1, Keyword = "" }; } List <ShipmentViewDTO> lsResult = null; try { using (var db = ContextFactory.UsTransportEntities()) { lsResult = db.tblShipments .Where(x => !x.IsDeleted && (x.WarehouseId == model.WarehouseId || model.WarehouseId == -1) && (x.CreateTime <= model.ToTime && x.CreateTime >= model.FromTime) ) .Select(x => new ShipmentViewDTO { Destination = x.Destination ?? 0, Id = x.Id, ShipmentCode = x.ShipmentCode, TotalWeight = x.TotalWeight ?? 0, WarehouseId = x.WarehouseId ?? 0, CreateTime = x.CreateTime ?? 0 }).ToList(); } if (lsResult != null && lsResult.Any()) { var dicPackage = Shipment_GetLstPackage_Dic(lsResult.Select(x => x.Id).Distinct().ToList()); var dicWarehouser = Shipment_GetLstWareHouse_Dic(lsResult.Select(x => x.WarehouseId).Distinct().ToList()); var lstPackage = new List <tblPackageInfo>(); var warehouse = new tblWarehouse(); foreach (var item in lsResult) { dicPackage.TryGetValue(item.Id, out lstPackage); dicWarehouser.TryGetValue(item.WarehouseId, out warehouse); item.WarehouseName = warehouse?.Warehouse; if (lstPackage != null) { var lstOrder = Package_GetLstOrderByOrderIds(lstPackage.Select(x => x.OrderId).Distinct().ToList()); var lstShippingRecipientInfo = Order_GetLstShippingInfo((int)OrderUserInfo.Recipient, lstOrder.Select(x => x.id).ToList()); if (lstPackage != null && lstPackage.Any()) { item.LstPackage = new List <PackageViewDTO>(); var dicItem = Package_GetLstItem_Dic(lstPackage.Select(x => x.id).Distinct().ToList()); var lstStoreAcount = _orderService.Order_GetLstStoreAcountInfo(lstPackage.Select(x => x.StoreId).Distinct().ToList()); foreach (var p in lstPackage) { var recipientInfo = lstShippingRecipientInfo.FirstOrDefault(x => x.OrderId == p.OrderId); var op = p.Map <PackageViewDTO>(); op.Id = p.id; op.StatusId = p.Status; op.Destination = p.Destination ?? 0; op.DestinationName = Common.ServiceHelper.GetDestionationCodeById(p.Destination ?? 0); op.StatusName = ((Models.Extension.Constant.OrderStatusInfo)p.Status).ToString(); op.StoreName = lstStoreAcount.FirstOrDefault(x => x.id == p.StoreId)?.FullName; op.CreateTime = p.CreateTime; op.ShipmentId = p.ShipmentId ?? 0; op.WarehouseId = p.WarehouseId ?? 0; dicWarehouser.TryGetValue(op.WarehouseId, out warehouse); op.WarehouseName = warehouse?.Warehouse; op.RecipientCityName = recipientInfo?.CityName; var lstItem = new List <tblItemInPackage>(); dicItem.TryGetValue(p.id, out lstItem); op.Items = new List <ItemPackageViewDTO>(); if (lstItem != null && lstItem.Any()) { foreach (var i in lstItem) { var idto = i.Map <ItemPackageViewDTO>(); idto.CategoryCode = i.Code; op.Items.Add(idto); } } item.LstPackage.Add(op); } item.TotalPackage = item.LstPackage.Count(); item.DestinationName = Common.ServiceHelper.GetDestionationCodeById(item.Destination); } } } } } catch (Exception ex) { SELog.WriteLog("ShipmentService => Admin_SearchShipment", ex); } return(lsResult); }
public async Task <ShipmentList> Search(ShipmentSearch req) => await new Search(req).GetResult();