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); }