示例#1
0
        public async Task <ActionResult <ApplicationUserViewModel> > GetUser(string id)
        {
            ApplicationUser user = await _userRepository.FindByIdAsync(id);

            if (user == null)
            {
                return(NotFound("El usuario solicitado no se encuentra registrado"));
            }

            return(_mapper.Map <ApplicationUserViewModel>(user));
        }
示例#2
0
        public async Task <ClientAccountModel> GetClientAccountAsync(string token)
        {
            SessionData session = await sessionRepository.GetByTokenAsync(token);

            UserData user = await applicationUserRepository.FindByIdAsync(session.UserId);

            ClientData client  = clientRepository.FindByUser(user);
            var        account = new ClientAccountModel()
            {
                ClientId    = client.Id,
                Email       = user.Email,
                Passport    = client.Passport,
                Telephone   = client.Telephone,
                Name        = client.Name,
                Surname     = client.Surname,
                PhotoPath   = client.PhotoPath,
                Role        = applicationRoleRepository.Get(user.RoleId).Name,
                CreditCards = await creditCardRepository.GetByClientAsync(client.Id)
            };

            return(account);
        }
示例#3
0
        public async Task <ClientData> GetClientAsync(string token)
        {
            SessionData session = await sessionRepository.GetByTokenAsync(token);

            if (session == null)
            {
                return(null);
            }

            UserData user = await applicationUserRepository.FindByIdAsync(session.UserId);

            if (user == null)
            {
                return(null);
            }

            return(clientRepository.FindByUser(user));
        }
示例#4
0
        public async Task <DefaultResponseModel> AddAsync(AddOrderModel addOrderModel)
        {
            DefaultResponseModel response = new DefaultResponseModel {
                IsSuccessful = false, Message = string.Empty
            };
            SessionData session = await sessionRepository.GetByTokenAsync(addOrderModel.Token);

            if (session == null)
            {
                response.Message = "Unathorized user";
                return(response);
            }
            if (!await roomAvailabilityHandler.AreBookingDatesValid(addOrderModel))
            {
                response.Message = "Dates are not valid";
                return(response);
            }
            if (!await roomAvailabilityHandler.IsRoomAvailableAsync(addOrderModel))
            {
                response.Message = "Room already booked for this dates";
                return(response);
            }

            UserData user = await applicationUserRepository.FindByIdAsync(session.UserId);

            ClientData client = await clientRepository.FindByIdAsync(user.Id);

            var orderData = new OrderData
            {
                Name     = addOrderModel.Name,
                Surname  = addOrderModel.Surname,
                RoomId   = addOrderModel.RoomId,
                CheckIn  = addOrderModel.CheckIn,
                CheckOut = addOrderModel.CheckOut,
                ClientId = client.Id,
            };
            OrderData addedOrder = await orderRepository.AddAsync(orderData);

            response.IsSuccessful = true;
            return(response);
        }
示例#5
0
 public Task <ApplicationUser> FindByIdAsync(string userId)
 {
     return(_userRepository.FindByIdAsync(userId));
 }