public object Login(string userName, string password, bool isRemmberMe)
        {
            CheckedService CheckedS = new CheckedService(db);
            CreateService  CreateS  = new CreateService(db);

            UserService UserS   = new UserService();
            string      Culture = LanguageService.DefaultLangage;

            UserVM UserData = new UserVM
            {
                Id       = db.Users_CheckFromUserNameIsValid(userName).First(),
                UserName = userName,
                Password = password
            };

            //Create User Login And Check Is Block
            //Check User Name Used
            if (!UserData.Id.HasValue)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.InvalidData));
            }

            //Add User Login With Statues Login Right Now
            User User = CreateS.UserLogin(UserData);

            if (User == null)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.InvalidData));
            }


            if (User.IsPhoneActivated == false)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.YouAreNotActive, new
                {
                    IsActivePhone = false,
                    UserInformation = new
                    {
                        PhoneNumber = User.PhoneNumber
                    }
                }));
            }

            //Check last Login is Block
            if (User.IsBlocked)
            {
                //retuen message Account Block
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.YoureAccountIsBlocked));
            }
            else
            //Check last Login Statues
            if (!User.IsSuccessLogin)
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.InvalidData));
            }

            /*
             * Check user role mustbe if Client or Client
             **Notes** any user login in app basically included role client
             */
            if (!CheckedS.Roles(User.UserRoles, new int[] { RoleEnumVM.Client }))
            {
                return(new ResponseVM(RequestTypeEnumVM.Error, Token.YouNotClient));
            }

            Culture = User.LanguageType.Code;

            LanguageService.SetCulture(Culture);
            //Now Create Access Token
            AccessTokenVM AccessToken = CreateS.CreateToken(User, Culture, isRemmberMe);
            ResponseVM    Res         = new ResponseVM();

            Res.RequestType = RequestTypeEnumVM.Success;
            Res.Data        = new
            {
                IsActivePhone   = true,
                UserInformation = new UsersData().GetUserIformation(User.Id),
                AccessToken
            };
            //return the token
            return(Res);
        }
 public UpdateService(TageerEntities _db)
 {
     this.CheckedS = new CheckedService(_db);
     this.db       = _db;
 }