/// <summary>
        /// Converts model to viewmodel
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static ResourceAvailabilityViewModel ToViewModel(this ResourceAvailabilityModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new ResourceAvailabilityViewModel
            {
                AvailabilityEndTime   = entity.AvailabilityEndTime,
                AvailabilityStartTime = entity.AvailabilityStartTime,
                Days                   = (string)GetDayOfWeekLookup().First(x => x.ID == entity.DayOfWeekID).Name,
                FacilityID             = entity.FacilityID,
                ResourceAvailabilityID = entity.ResourceAvailabilityID,
                ResourceID             = entity.ResourceID,
                ResourceTypeID         = entity.ResourceTypeID,
                ModifiedOn             = entity.ModifiedOn
            };

            var schedtype = GetScheduleTypeLookup().FirstOrDefault(x => x.ID == entity.ScheduleTypeID);

            model.ScheduleType = (schedtype == null) ? "" : (string)schedtype.ScheduleType;

            return(model);
        }
Exemple #2
0
        /// <summary>
        /// Updates a resource availability.
        /// </summary>
        /// <param name="resourceAvailability"></param>
        /// <returns></returns>
        public Response <ResourceAvailabilityViewModel> UpdateResourceAvailability(ResourceAvailabilityViewModel resourceAvailability)
        {
            const string apiUrl = baseRoute + "UpdateResourceAvailability";

            return
                (communicationManager.Put <ResourceAvailabilityModel, Response <ResourceAvailabilityModel> >(resourceAvailability.ToModel(), apiUrl)
                 .ToViewModel());
        }
        /// <summary>
        /// Converts viewmodel to model
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static ResourceAvailabilityModel ToModel(this ResourceAvailabilityViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new ResourceAvailabilityModel
            {
                AvailabilityEndTime    = model.AvailabilityEndTime,
                AvailabilityStartTime  = model.AvailabilityStartTime,
                DayOfWeekID            = (int)GetDayOfWeekLookup().First(x => x.Name == model.Days).ID,
                ScheduleTypeID         = (short)GetScheduleTypeLookup().First(x => x.ScheduleType == model.ScheduleType).ID,
                FacilityID             = model.FacilityID,
                ResourceAvailabilityID = model.ResourceAvailabilityID,
                ResourceID             = model.ResourceID,
                ResourceTypeID         = model.ResourceTypeID,
                ModifiedOn             = model.ModifiedOn
            };

            return(entity);
        }
Exemple #4
0
        public Response <ResourceAvailabilityViewModel> UpdateResourceAvailability(ResourceAvailabilityViewModel resourceAvailability)
        {
            var response = resourceRepository.UpdateResourceAvailability(resourceAvailability);

            return(response);
        }
Exemple #5
0
 public Response <ResourceAvailabilityViewModel> AddResourceAvailability(ResourceAvailabilityViewModel resourceAvailability)
 {
     return(resourceRepository.AddResourceAvailability(resourceAvailability));
 }