Exemplo n.º 1
0
        /// <summary>
        /// GetAvailableEquipment -
        /// Requesting both to cancel the current booking date
        /// and provide New availability of EquipmentID for the new request date
        /// </summary>
        /// <param name="requestDate"></param>
        /// <param name="newRequestDate"></param>
        /// <returns></returns>
        public int GetAvailableEquipment(DateTime requestDate, DateTime newRequestDate)
        {
            if (_equipmentSetting.Environment == "Production")
            {
                using (var _client = new HttpClient())
                {
                    //calling external equipment availability api and getting availability status
                    _client.BaseAddress = new Uri(_equipmentSetting.Uri);
                    _client.DefaultRequestHeaders.Accept.Clear();

                    //TODO: Making a request to return availability status??
                }
            }
            else
            {
                // cancelling of existing appointment
                // providing new availability for the new request date

                var equipment = JsonFileHelper.GetEquipmentAvailability(_equipmentSetting.DataFile);

                var equipmentId = equipment
                                  .Where(e => e.isAvailable == true &&
                                         e.Date >= newRequestDate)
                                  .Select(x => x.EquipmentID)
                                  .FirstOrDefault();

                return(equipmentId);
            }

            return(0);
        }