Example #1
0
        public object Get(int ID)
        {
            var trip        = service.Get(ID);
            var apartment   = apartmentService.GetAll();
            var tripToBoard = new
            {
                ArrivalCountry   = trip.ArrivalOffice.Country,
                ArrivalCity      = trip.ArrivalOffice.City,
                DepartureCountry = trip.DepartureOffice.Country,
                DepartureCity    = trip.DepartureOffice.City,
                ReturnDate       = trip.ReturnDate,
                DepartureDate    = trip.DepartureDate,
                Status           = trip.Status,

                Employees = trip.EmployeesToTrip.ToInfo(),

                Tickets = trip.PlaneTickets?.ToInfo(),

                trip.IsPlaneNeeded,

                Reservations = trip.Reservations?.ToInfo(),

                trip.IsCarRentalNeeded,
                Rentals = trip.CarRentals?.ToInfo(),

                trip.IsCarCompensationNeeded,
                GasCompensations = trip.GasCompensations?.ToInfo(),
            };

            return(tripToBoard);
        }
Example #2
0
        public IActionResult GetAll()
        {
            var result = _customerService.GetAll();

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Example #3
0
 public ActionResult Get([FromQuery] int?projectid)
 {
     if (projectid.HasValue)
     {
         return(Ok(apartmentService.GetApartmentsByProjectId(projectid.Value)));
     }
     else
     {
         return(Ok(apartmentService.GetAll()));
     }
 }
        public async Task FillBotAsync()
        {
            BotCache        botCache = null;
            List <BotCache> inCache  = null;

            var apartments = await _apartmentService.GetAll();

            //var infos = await _infoService.GetAll();
            //var events = await _eventService.GetAll();

            foreach (var apartment in apartments)
            {
                var split = apartment.Utilities.Split('&');

                foreach (var utility in split)
                {
                    var utilitySplit = utility.Split('=');
                    botCache = new BotCache(utilitySplit[0], utilitySplit[1],
                                            apartment.ApartmentId);

                    inCache = await(_botCacheRepository.GetAllWhere(
                                        m => m.ApartmentId == apartment.ApartmentId &&
                                        m.Keyword == utilitySplit[0]));

                    if (!inCache.Any())
                    {
                        _botCacheRepository.Insert(botCache);
                    }
                }

                var inTime  = apartment.CheckIn.TimeOfDay.ToString();
                var outTime = apartment.CheckOut.TimeOfDay.ToString();

                botCache = new BotCache("check", inTime + "&" + outTime, apartment.ApartmentId);

                inCache = await _botCacheRepository.GetAllWhere(m => m.ApartmentId == apartment.ApartmentId &&
                                                                m.Keyword == "check");

                if (!inCache.Any())
                {
                    _botCacheRepository.Insert(botCache);
                }
            }
        }
Example #5
0
 public HttpResponseMessage GetAll(HttpRequestMessage request, string keyword, int page, int pageSize = 20)
 {
     return(CreateHttpResponse(request, () =>
     {
         int totalRow = 0;
         var model = _apartmentService.GetAll(keyword);
         totalRow = model.Count();
         var query = model.OrderByDescending(x => x.CreatedDate).Skip(page * pageSize).Take(pageSize);
         var responseData = Mapper.Map <IEnumerable <Apartment>, IEnumerable <ApartmentViewModel> >(query.AsEnumerable());
         var paginationSet = new PaginationSet <ApartmentViewModel>()
         {
             Items = responseData,
             Page = page,
             TotalCount = totalRow,
             TotalPages = (int)Math.Ceiling((decimal)totalRow / pageSize)
         };
         var response = request.CreateResponse(HttpStatusCode.OK, paginationSet);
         return response;
     }));
 }
Example #6
0
        private async Task <List <Apartment> > GetApartmentsAsync(LocationApi location)
        {
            List <Apartment> apartments = await _apartmentService.GetAll();

            List <Apartment> nearby = new List <Apartment>();

            foreach (var apartment in apartments)
            {
                var apartmentLocation = _locationService.GetById(apartment.LocationId.ToString());
                var inRadius          = Math.Pow((location.Latitude - apartmentLocation.Latitude) * DegreeToKm, 2)
                                        + Math.Pow((location.Longitude - apartmentLocation.Longitude) * DegreeToKm, 2) <=
                                        Math.Pow(Radius, 2);

                if (inRadius)
                {
                    nearby.Add(apartment);
                }
            }

            return(nearby);
        }
Example #7
0
        public ActionResult <IEnumerable <ApartmentModel> > GetApartments()
        {
            var apartments = _apartmentService.GetAll();

            return(Ok(apartments));
        }
Example #8
0
        // GET api/apartments
        public HttpResponseMessage Get()
        {
            var items = _apartmentService.GetAll().Select(x => x.ToViewModel());

            return(Request.CreateResponse(System.Net.HttpStatusCode.Accepted, items));
        }
 public async Task <IEnumerable <ApartmentViewModel> > GetAll()
 {
     return(await _apartmentService.GetAll());
 }