Пример #1
0
        public static AuthenticationType GetAuthenticationTypeForRestaurantUser(int userid)
        {
            var result = (AuthenticationType)(-1);

            if (userid > 0)
            {
                var user = new RestaurantUserRepository().Find(userid);
                if (user != null)
                {
                    var restaurantuser = RestaurantUserRepository.UserBaseToRestaurantUser(user);
                    if (restaurantuser.UserRole == UserBase.RestaurantUserRole.Guest)
                    {
                        result = AuthenticationType.Guest;
                    }
                    if (restaurantuser.UserRole == UserBase.RestaurantUserRole.Customer && restaurantuser.FacebookDetail != null && restaurantuser.FacebookDetail.FacebookId > 0)
                    {
                        result = AuthenticationType.Facebook;
                    }
                    if (restaurantuser.UserRole == UserBase.RestaurantUserRole.Customer && (restaurantuser.FacebookDetail == null || restaurantuser.FacebookDetail.FacebookId < 1))
                    {
                        result = AuthenticationType.Normal;
                    }
                    if (restaurantuser.UserRole == UserBase.RestaurantUserRole.Employee || restaurantuser.UserRole == UserBase.RestaurantUserRole.Admin)
                    {
                        result = AuthenticationType.Normal;
                    }
                }
            }
            return(result);
        }
Пример #2
0
        public IEnumerable <RestaurantUser> GetAllUsers()
        {
            int totalrecords;
            var membershipusers = _provider.GetAllUsers(0, Int32.MaxValue, out totalrecords);
            var restaurantusers = new RestaurantUserRepository().SelectAll();
            var result          = new List <RestaurantUser>(restaurantusers.Count());

            try
            {
                foreach (var user in restaurantusers)
                {
                    var restaurantuser     = RestaurantUserRepository.UserBaseToRestaurantUser(user);
                    var membershipusername = restaurantuser.UserRole == UserBase.RestaurantUserRole.Guest
                                                 ? restaurantuser.UserGuid.ToString()
                                                 : (restaurantuser.FacebookDetail != null &&
                                                    restaurantuser.FacebookDetail.FacebookId > 0 &&
                                                    !restaurantuser.FacebookDetail.OAuthToken.IsNullOrEmpty())
                                                       ? restaurantuser.FacebookDetail.FacebookId.ToString()
                                                       : restaurantuser.EmailId;
                    var membershipuser = membershipusers[membershipusername];
                    if (membershipuser != null)
                    {
                        result.Add(new RestaurantUser(restaurantuser.UserId, restaurantuser.Name, restaurantuser.UserGuid,
                                                      restaurantuser.MobileNumber, restaurantuser.LoginExpiresOn,
                                                      restaurantuser.UserRole, restaurantuser.Address, restaurantuser.EmailId,
                                                      restaurantuser.Password, restaurantuser.FacebookDetail,
                                                      membershipuser));
                    }
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            {
                throw;
            }
            // ReSharper restore EmptyGeneralCatchClause

            return(result);
        }
        /// <summary>
        /// Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUser"/> object populated with the specified user's information from the data source.
        /// </returns>
        /// <param name="username">The name of the user to get information for. </param><param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user. </param>
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            var restaurantresult = (RestaurantUser)null;
            var sqlresult        = (MembershipUser)null;

            if (username != null)
            {
                sqlresult = base.GetUser(username, userIsOnline);
                if (sqlresult != null && sqlresult.ProviderUserKey != null && sqlresult.ProviderUserKey is Guid)
                {
                    restaurantresult =
                        RestaurantUserRepository.UserBaseToRestaurantUser(UserRepository.Find((Guid)sqlresult.ProviderUserKey));
                }
            }

            if (restaurantresult != null)
            {
                restaurantresult = CombineResult(restaurantresult, sqlresult);
            }

            return(restaurantresult);
        }
        /// <summary>
        /// Gets user information from the data source based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUser"/> object populated with the specified user's information from the data source.
        /// </returns>
        /// <param name="providerUserKey">The unique identifier for the membership user to get information for.</param><param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param>
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            var restaurantresult = (RestaurantUser)null;
            var sqlresult        = (MembershipUser)null;

            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            if (providerUserKey != null && (providerUserKey is Guid))
            // ReSharper restore ConditionIsAlwaysTrueOrFalse
            {
                sqlresult = base.GetUser(providerUserKey, userIsOnline);
                if (sqlresult != null)
                {
                    restaurantresult =
                        RestaurantUserRepository.UserBaseToRestaurantUser(UserRepository.Find((Guid)providerUserKey));
                }
            }

            if (restaurantresult != null)
            {
                restaurantresult = CombineResult(restaurantresult, sqlresult);
            }

            return(restaurantresult);
        }