/// <summary>
        /// Load history data from DB converting to List of IWorkOrderModel
        /// Out errorMessage if data not loaded
        /// </summary>
        public IEnumerable <IOrderViewModel> GetMasterOrder(int orderId, string accessToken, out string errorMessage)
        {
            errorMessage = string.Empty;

            var result = new List <IOrderViewModel>();

            var order = WebApiWorker.GetResult <LaborDetail.Item>(apiLaborDetail + "/LaborDetail/Get/" + orderId, accessToken, out errorMessage);

            if (string.IsNullOrEmpty(errorMessage))
            {
                var labor = new BasicWorkViewModel(_directoryManager, _orderItemFactory);
                labor.ConvertToViewModel(order);
                result.Add(labor);
                foreach (var item in order.SubLaborDetails)
                {
                    var additionalLabor = new AdditionalWorkViewModel(_directoryManager, _orderItemFactory);
                    additionalLabor.ConvertToViewModel(item);
                    result.Add(additionalLabor);
                }

                if (order.ManualOperations.Count > 0 || order.Employees.Count > 0)
                {
                    var manual = new ManualWorkViewModel(_directoryManager, _orderItemFactory);
                    manual.ConvertToViewModel(order);
                    result.Add(manual);
                }

                foreach (var i in result)
                {
                    i.Index = result.IndexOf(i);
                }
            }

            return(result);
        }
        /// <summary>
        /// Check is order can be canceled by id if it doesn't have any autodetected works inside
        /// </summary>
        public bool?IsOrderCanBeCanceled(int orderId, string accessToken)
        {
            string errorMessage = "";

            var canBeCanceled = WebApiWorker.GetResult <bool?>(apiLaborDetail + "/LaborDetail/GetCanCancel/" + orderId, accessToken, out errorMessage);

            return(canBeCanceled);
        }
        /// <summary>
        /// Save collection of IOrderViewModel converting to service data type
        /// Out errorMessage if data id not saved
        /// </summary>
        public IEnumerable <IOrderModel> GetActiveOrders(string accessToken, out string errorMessage)
        {
            errorMessage = null;
            var laborDetailFilter = new LaborDetail.Filter();

            laborDetailFilter.IsActive = true;

            List <IOrderModel> result = new List <IOrderModel>();

            var orders = WebApiWorker.GetResult <List <LaborDetail.ListItem> >(apiLaborDetail + "/LaborDetail/Get", accessToken, out errorMessage, laborDetailFilter);

            if (string.IsNullOrEmpty(errorMessage))
            {
                result = ConvertToWorkModel(orders);
            }

            return(result);
        }
        /// <summary>
        /// Load active data from DB converting to List of IWorkOrderModel
        /// Out errorMessage if data not loaded
        /// </summary>
        public IEnumerable <IOrderModel> GetHistoryOrders(int page, IFilterModel filter, string accessToken, out string errorMessage)
        {
            errorMessage = null;

            var laborDetailFilter = filter.ConvertFromModel <LaborDetail.Filter>();

            laborDetailFilter.IsActive = false;
            laborDetailFilter.Page     = page;

            List <IOrderModel> result = new List <IOrderModel>();

            var orders = WebApiWorker.GetResult <List <LaborDetail.ListItem> >(apiLaborDetail + "/LaborDetail/Get", accessToken, out errorMessage, laborDetailFilter);

            if (string.IsNullOrEmpty(errorMessage))
            {
                result = ConvertToWorkModel(orders);
            }

            return(result);
        }