Exemple #1
0
        public async Task <HttpResponseMessage> GetVisitForHotel([FromUri] string hotelName)
        {
            //Initialize the mapperList
            var configList = new MapperConfiguration(cfg =>
                                                     cfg.CreateMap <Guest, GuestRestBasicInfo>()
                                                     );
            List <Guest> GuestsInHotel = new List <Guest>();

            GuestsInHotel = await TempServiceHotels.GetVisitForHotel(hotelName);

            List <GuestRestBasicInfo> PrintGuests = new List <GuestRestBasicInfo>();

            if (GuestsInHotel.Count == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound, "There are no Hotels"));
            }
            var mapper = new Mapper(configList);

            //ostavljen foreach jer mi se u automapp gubi info pronadem rijesenje za vikend
            foreach (Guest guest in GuestsInHotel)
            {
                GuestRestBasicInfo guestBasic = mapper.Map <GuestRestBasicInfo>(guest);
                PrintGuests.Add(guestBasic);
            }

            //List<GuestRestBasicInfo> printGuest = mapper.Map<List<GuestRestBasicInfo>>(TempServiceHotels.GetVisitForHotel(hotelName));


            return(Request.CreateResponse(HttpStatusCode.OK, PrintGuests));
        }
Exemple #2
0
        public async Task <HttpResponseMessage> DeleteGuest([FromBody] GuestRestBasicInfo guest)
        {
            //Initialize the mapper
            var config = new MapperConfiguration(cfg =>
                                                 cfg.CreateMap <GuestRestBasicInfo, Guest>()
                                                 );
            var   mapper   = new Mapper(config);
            Guest newGuest = mapper.Map <Guest>(guest);

            if (await TempServiceHotels.DeleteGuest(newGuest))
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Guest Deleted"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }