public static UserModel MapAspNetUserToUserModel(AspNetUser user)
        {
            var userModel = new UserModel
            {
                Id                = user.Id,
                FName             = user.FirstName,
                LName             = user.LastName,
                Email             = user.Email,
                EmailConfirmed    = user.EmailConfirmed,
                AccessFailedCount = user.AccessFailedCount,
                Active            = user.Enabled,
                Birthday          = user.Birthday,
                DateCreated       = user.DateCreated,
                HashOfPassword    = user.PasswordHash,
                LockoutEndDateUtc = user.LockoutEndDateUtc,
                PhoneNr           = user.PhoneNumber,
                Username          = user.UserName,
                SecurityStamp     = user.SecurityStamp,
                TwoFactorEnabled  = user.TwoFactorEnabled,
                AnonymousRequest  = MapAnonymousRequestToARModel(user.AnonymousRequest)
            };

            userModel.Bookings       = user.Bookings.Select(b => BookingMappings.MapBookingToBookingModel(b, userModel)).ToList();
            userModel.DriverServices = user.DriverServices.Select(ds => DriverServiceMappings.MapDriverServiceToDriverServiceModel(ds, null, userModel)).ToList();
            userModel.UserRoles      = user.AspNetRoles.Select(r => RoleMappings.MapRoleToRoleModel(r)).ToList();
            return(userModel);
        }
Exemplo n.º 2
0
        public static BookingModel MapBookingToBookingModel(Booking booking, UserModel @user)
        {
            var @return = new BookingModel
            {
                Id       = booking.Id,
                BookTime = booking.BookingTime,
                Start    = booking.StartDate,
                End      = booking.EndDate,
                Valid    = booking.Valid,
                CheckIn  = booking.CheckIn,
                CheckOut = booking.CheckOut,
                ClientId = booking.UserId
            };

            @return.Client = @user;

            @return.Rating = booking.Rating != null?MapRatingToRatingModel(booking.Rating, @return) : null;

            @return.BookingRooms = booking.BookingRooms?.Select(br => MapBookingRoomToBookingRoomModel(br, @return,
                                                                                                       RoomMappings.MapRoomToRoomModel(br.Room, null))).ToList();
            @return.DriverServices = booking.DriverServices?.Select(ds => DriverServiceMappings.MapDriverServiceToDriverServiceModel(ds, @return, null)).ToList();
            return(@return);
        }