public HttpResponseMessage GetUserReservations(IncomingGetUsersReservations model) { return(ErrorFactory.Handle(() => { using (var unitOfWork = new UnitOfWork()) { var userId = User?.Identity?.GetUserId(); if (string.IsNullOrWhiteSpace(userId)) { throw new Exception(); } if (model == null) { throw new InvalidModelException(); } var reservations = unitOfWork.Reservations.GetReservationsForUser(userId, model.UserId, model.StartDate, model.EndDate); var outgoingReservations = reservations?.Select(x => OutgoingMinimalReservationGroupExtra.Parse(x)); return JsonFactory.CreateJsonMessage(outgoingReservations, HttpStatusCode.OK, this.Request); } }, this.Request)); }
public HttpResponseMessage SearchAllReservations(IncomingSearchAllReservation model) { return(ErrorFactory.Handle(() => { using (var unitOfWork = new UnitOfWork()) { var userId = User?.Identity?.GetUserId(); if (string.IsNullOrWhiteSpace(userId)) { throw new Exception(); } var reservations = unitOfWork.Reservations.SearchAllReservations(userId, model.Query, model.SearchType, model.StartDate, model.EndDate).ToList(); var outgoingReservations = reservations.Select(x => OutgoingMinimalReservationGroupExtra.Parse(x)).ToList(); return JsonFactory.CreateJsonMessage(outgoingReservations, HttpStatusCode.OK, this.Request); } }, this.Request)); }