示例#1
0
        public ReservationListViewModel initialize()
        {
            //MOCK
            //user = new User() { Id = Guid.NewGuid() };
            //reservationMock = new ReservationMock(user);
            //reservationsList = reservationMock.GetReservationsByUserId(user.Id);


            _proxy = AutofacHelper.Container.Resolve <ApiClientProxy>();



            var user = (User)Application.Current.Properties["UserData"];
            //var user = _proxy.Get<User>("User");
            var response = _proxy.Get <ApiResponse <List <Reservation> > >($"Reservation/User/{user.Id}");

            if (response?.Code == ApiResponseCode.OK)
            {
                reservationsList     = response.Value;
                ReservationListItems = new ObservableCollection <ReservationListItem>();

                foreach (Reservation reservation in reservationsList)
                {
                    var apiResponse = _proxy.Get <ApiResponse <Resource> >($"Resource/Guid={reservation.ResourceId}");
                    if (apiResponse?.Code == ApiResponseCode.OK)
                    {
                        var resource = apiResponse.Value;
                        ReservationListItems.Add(new ReservationListItem()
                        {
                            Id          = reservation.Id,
                            From        = reservation.Timeslot.FromDate,
                            To          = reservation.Timeslot.ToDate,
                            UserId      = reservation.UserId,
                            ResourceId  = resource.Id,
                            Description = resource.Description,
                            Name        = resource.Name
                        });
                    }
                }
            }
            return(this);
        }
示例#2
0
 public void UpdateUser(User user = null)
 {
     user = _proxy.Get <ApiResponse <User> >("User").Value;
     Application.Current.Properties["UserData"] = user;
 }