public ActionResult Search(OrderSearchModel model) { var Msg = new Message(); try { List <DVG.WIS.PublicModel.OrderOnListModel> listOrders = new List <DVG.WIS.PublicModel.OrderOnListModel>(); int totalRow = 0; listOrders = _orderBo.GetList(model.KeyWord, model.Status, model.SourceType, model.DeliveryStatus, model.OrderType, model.FromCreatedDate, model.ToCreatedDate, model.RequestType, out totalRow, model.PageIndex, model.PageSize).ToList(); List <District> listDistrict = _districtBoCached.GetAll().ToList(); // nếu là màn hình bếp => lấy list Món ra var isDisplayListOrderDetails = (_userService.GetRole() == UserTypeEnum.Kitchen.GetHashCode() || _userService.GetRole() == UserTypeEnum.Checkfood.GetHashCode()) && (model.Status == OrderStatusEnum.Pending.GetHashCode() || model.Status == OrderStatusEnum.PushToPOS.GetHashCode() || model.Status == OrderStatusEnum.KitchenAccept.GetHashCode() || model.Status == OrderStatusEnum.KitchenDone.GetHashCode()); if (listOrders.Any()) { foreach (var item in listOrders) { var district = listDistrict.Find(x => x.district_id == item.DistrictId); if (district != null) { item.DistrictStr = district.district_name; } if (isDisplayListOrderDetails) { item.lstOrderDetail = _orderBo.GetByOrderId(item.OrderId); } } } var pager = new Pager { CurrentPage = model.PageIndex, PageSize = model.PageSize, TotalItem = totalRow }; Msg.Obj = new { SearchModel = model, Data = listOrders, Pager = pager }; } catch (Exception ex) { Msg.Obj = null; Msg.Title = ex.Message; Msg.Error = true; } return(AuthorizeJson(Msg)); }
public ActionResult Search(OrderSearchModel model) { ResponseData responseData = new ResponseData(); try { List <DVG.WIS.PublicModel.OrderOnListModel> listOrders = new List <DVG.WIS.PublicModel.OrderOnListModel>(); int totalRow = 0; listOrders = _orderBo.GetList(model.KeyWord, model.Status, model.SourceType, model.DeliveryStatus, model.OrderType, model.FromCreatedDate, model.ToCreatedDate, model.RequestType, out totalRow, model.PageIndex, model.PageSize).ToList(); List <District> listDistrict = (List <District>)_districtBoCached.GetAll(); // nếu là màn hình bếp => lấy list Món ra var isDisplayListOrderDetails = _userService.GetRole() == UserTypeEnum.Kitchen.GetHashCode() && (model.Status == OrderStatusEnum.PushToPOS.GetHashCode() || model.Status == OrderStatusEnum.KitchenAccept.GetHashCode()); if (listOrders.Any()) { foreach (var item in listOrders) { var district = listDistrict.Find(x => x.district_id == item.DistrictId); if (district != null) { item.DistrictStr = district.district_name; } if (isDisplayListOrderDetails) { item.lstOrderDetail = _orderBo.GetByOrderId(item.OrderId); } } } responseData.Data = listOrders; responseData.TotalRow = totalRow; responseData.Success = true; } catch (Exception ex) { responseData.Data = null; responseData.Success = false; } return(Json(responseData)); }
public OrderViewModel GetById(int id) { OrderViewModel orderModel = new OrderViewModel(); try { var order = _orderDal.GetById(id); if (order != null && order.order_id > 0) { var lstDistrict = _districtBoCached.GetAll().ToList(); var lstWard = _wardBoCached.GetAll().ToList(); var district = lstDistrict.Find(x => x.district_id == order.district_id); var ward = lstWard.Find(x => x.ward_id == order.ward_id); var listOrderDetail = _orderDetailDal.GetByOrderId(id).Select(x => new OrderDetailViewModel(x)).ToList(); orderModel = new OrderViewModel(order, district, ward, listOrderDetail); } } catch (Exception ex) { Logger.Error(ex); } return(orderModel); }