Inheritance: TableStorageEntity
Exemplo n.º 1
0
        public string UserLogin(LoginProperties data)
        {
            if (data == null)
            {
                return MISSING;
            }

            try
            {
                JavaScriptSerializer json = new JavaScriptSerializer();
                UserEntity auth = new UserEntity();

                auth.UserName = data.UserName;
                auth.Password = GetHashPassword(data.Password);

                if (!string.IsNullOrEmpty(auth.UserName))
                {
                    TableManager tblMgr = new TableManager();
                    UserEntity user = tblMgr.GetUserByName(auth.UserName);

                    if (user != null && user.UserName == auth.UserName && user.Password == auth.Password)
                    {
                        return Login(user.UserId, user.UserType, user.FirstName, user.LastName, user.Email, user.Mobile, user.DateOfBirth, user.Gender, user.City, user.Favorite);
                    }
                    else
                    {
                        return INVALID;
                    }
                }
                else
                {
                    return MISSING;
                }
            }
            catch (Exception)
            {
                return ERROR;
            }
        }
Exemplo n.º 2
0
        public UserEntity(UserEntity entity)
            : base(PARTITION_KEY, entity.RowKey)
        {
            UserId = entity.UserId;
            UserName = entity.UserName;
            Password = entity.Password;

            UserType = entity.UserType;
            FirstName = entity.FirstName;
            LastName = entity.LastName;
            Email = entity.Email;
            Mobile = entity.Mobile;
            DateOfBirth = entity.DateOfBirth;
            Gender = entity.Gender;
            City = entity.City;
            Profile_Pic_Http = entity.Profile_Pic_Http;
            Profile_Pic_Https = entity.Profile_Pic_Https;
            Country = entity.Country;
            Status = entity.Status;
            Created_At = entity.Created_At;
            Favorite = entity.Favorite;
            SiteFeedbackScore = entity.SiteFeedbackScore;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Return update the user if user is found
        /// </summary>
        /// <param name="store"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool UpdateUserById(this IStore store, UserEntity user)
        {
            Debug.Assert(user != null);
            var list = new List<UserEntity> { user };
            var retList = store.UpdateUsersById(list);

            Debug.Assert(retList.Count == 1);
            if (retList.Count > 0)
                return retList[retList.Keys.FirstOrDefault()];
            else
                return false;
        }
Exemplo n.º 4
0
 public static UserEntity CreateUserEntity(string userName, string password)
 {
     var userId = Guid.NewGuid().ToString();
     var entity = new UserEntity(userId);
     entity.UserId = userId;
     entity.UserName = userName;
     entity.Password = password;
     return entity;
 }
Exemplo n.º 5
0
        public string Register(UserDetails data)
        {
            if (data == null || string.IsNullOrEmpty(data.UserId))
            {
                return "ERROR";
            }

            // Validate the details before storing it in DB
            // Encrypt the password before storing it in DB
            try
            {
                JavaScriptSerializer json = new JavaScriptSerializer();
                TableManager tblMgr = new TableManager();

                IDictionary<string, UserEntity> users = tblMgr.GetUsersByName(data.UserId);
                if (users != null && users.Count > 0)
                {
                    return "OK";
                }

                if (data != null)
                {
                    UserEntity user = new UserEntity();
                    user.UserName = data.UserId;
                    user.Password = string.IsNullOrEmpty(data.UserType) ? GetHashPassword(data.Password) : data.Country; // Country field is having the access token
                    user.City = string.IsNullOrEmpty(data.City) ? string.Empty : data.City;
                    user.Created_At = DateTime.Now;
                    user.DateOfBirth = string.IsNullOrEmpty(data.DateOfBirth) ? string.Empty : data.DateOfBirth;
                    user.Email = data.Email;
                    //user.Country = string.IsNullOrEmpty(data.Country) ? string.Empty : data.Country;
                    user.Profile_Pic_Http = string.IsNullOrEmpty(data.ProfilePic) ? string.Empty : data.ProfilePic;
                    user.Profile_Pic_Https = string.IsNullOrEmpty(data.SecureProfilePic) ? string.Empty : data.SecureProfilePic;
                    user.FirstName = data.FirstName;
                    user.Gender = string.IsNullOrEmpty(data.Gender) ? string.Empty : data.Gender;
                    user.LastName = data.LastName;
                    user.Mobile = string.IsNullOrEmpty(data.UserType) ? string.Empty : data.Mobile;
                    user.UserId = user.RowKey = Guid.NewGuid().ToString();
                    user.UserType = string.IsNullOrEmpty(data.UserType) ? "Application" : data.UserType;
                    user.Status = 1;

                    tblMgr.UpdateUserById(user);
                }
            }
            catch (Exception ex)
            {
                return "ERROR";
            }

            return "OK";
        }