예제 #1
0
        public OutputData<UserData> Login(UserData user)
        {
            IUserRepository userRepository = _UserRepository ?? new UserRepository();

            Mapper.CreateMap<UserData, User>();

            User us = Mapper.Map<UserData, User>(user);

            //us.MobileNumber = user.MobileNumber;
            //us.Email = user.Email;
            //us.Password = user.Password;

            OutputData<UserData> ud = new OutputData<UserData>();

            if (userRepository.Login(us) != null)
            {
                ud.Success = 1;
                ud.Message = "Login successfully";
                ud.Result = null;
                return ud;
            }
            else
            {
                ud.Success = 0;
                ud.Message = "Failed to login";
                ud.Result = null;
                return ud;
            }
        }
예제 #2
0
 public OutputData<UserData> UpdateProfile(UserData user)
 {
     if (user != null)
     {
         IUserController userController = _UserController ?? new UserController();
         return userController.UpdateUser(user);
     }
     else{
         OutputData<UserData> userData = new OutputData<UserData>();
         userData.Success = 1;
         userData.Message = "User information is null";
         userData.Result = null;
         return userData;
     }
 }
예제 #3
0
 public OutputData<UserData> SignUp(UserData user)
 {
     try
     {
         if (user != null)
         {
             IUserController userController = _UserController ?? new UserController();
             return userController.SingUpUser(user);
         }
     }
     catch (Exception ex)
     {
         LoggingFactory.InitializeLogFactory(new Log4NetAdapter());
         ILogger log = LoggingFactory.GetLogger();
         log.Log(ex.Message);
         OutputData<UserData> userData = new OutputData<UserData>();
         userData.Success = 0;
         userData.Message = ex.Message;
         userData.Result = null;
         return userData;
     }
     return null;
 }
예제 #4
0
 public OutputData<UserData> VerifyUser(UserData user)
 {
     if (user != null)
     {
         IUserController userController = _UserController ?? new UserController();
         return userController.VerifyUser(user);
     }
     else
     {
         OutputData<UserData> userData = new OutputData<UserData>();
         userData.Success = 0;
         userData.Message = "Verify Code or UserIdentity is Empty or null";
         userData.Result = null;
         return userData;
     }
 }
예제 #5
0
        public OutputData<UserData> SingUpUser(UserData userdata)
        {
            IUserRepository userRepository = _UserRepository ?? new UserRepository();

            User us = new User();

            if (userdata.Email == "")
                us.Email = null;
            else
                us.Email = userdata.Email;

            if (userdata.MobileNumber == "")
                us.MobileNumber = null;
            else
                us.MobileNumber = userdata.MobileNumber;

            us.Password = userdata.Password;

            us.UserId = Guid.NewGuid();
            us.IsActive = 0;
            us.VerificationCode = GetRandomNumber().GenerateRandomNumber();

            //add new user to repository
            User NewUser = userRepository.Add(us);

            OutputData<UserData> ud = new OutputData<UserData>();

            if (NewUser != null)
            {
                if (NewUser.Email == "" || NewUser.Email != string.Empty)
                {
                    //send mail to register email id
                }
                else
                {
                    // send sms to register mobile number
                }

                UserData userD = new UserData();

                userD.Email = "";
                userD.MobileNumber = "";

                if (NewUser.VerificationCode != null)
                    userD.VerificationCode = NewUser.VerificationCode;

                if (NewUser.UserId != null)
                    userD.UserId = NewUser.UserId;

                userD.Password = "";
                userD.FirstName = "";
                userD.LastName = "";

                ud.Success = 1;
                ud.Message = "Signup Success";
                ud.Result = userD;
                return ud;
            }
            else
            {
                ud.Success = 0;
                ud.Message = "Failed to signup";
                ud.Result = null;
                return ud;
            }
        }
예제 #6
0
        public OutputData<UserData> VerifyUser(UserData userdata)
        {
            IUserRepository userRepository = _UserRepository ?? new UserRepository();

            OutputData<UserData> outputData = new OutputData<UserData>();

            User verifyUser = new User();
            verifyUser.VerificationCode = userdata.VerificationCode;
            verifyUser.UserId = userdata.UserId;

            if (userRepository.Verify(verifyUser) != null)
            {
                User user = userRepository.Get(verifyUser.UserId);
                user.IsActive = 1;
                userRepository.Update(user);

                outputData.Success = 1;
                outputData.Message = "User verified";
                outputData.Result = null;
            }
            else
            {
                outputData.Success = 0;
                outputData.Message = "User Unverified";
                outputData.Result = null;
            }

            return outputData;
        }
예제 #7
0
        public OutputData<UserData> UpdateUser(UserData user)
        {
            IUserRepository userRepository = _UserRepository ?? new UserRepository();

            User us = userRepository.Get(user.UserId);

            //Mapper.CreateMap<UserData, User>();

            //var mapping =  Mapper.Map<UserData,User>(user);

            us.FirstName = user.FirstName;
            us.LastName = user.LastName;
            us.DOB = user.DOB;
            us.City = user.City;
            us.Country = user.Country;
            us.State = user.State;
            us.Gender = user.Gender;
            us.Height = user.Height;
            us.Weight = user.Weight;

            if (user.MobileNumber != "")
                us.MobileNumber = user.MobileNumber;
            else if (user.Email != "")
                us.Email = user.Email;

            //FileStream targetStream = null;
            //Stream sourceStream = user.FileByteStream;
            //string uploadFolder = @"~\Run2GeoService.Infrastructure\UserProfileImages\";
            //string filePath = Path.Combine(uploadFolder, user.FileName);
            //using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
            //{
            //    const int bufferLen = 65000;
            //    byte[] buffer = new byte[bufferLen];
            //    int count = 0;
            //    while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
            //    {
            //        targetStream.Write(buffer, 0, count);
            //    }
            //    targetStream.Close();
            //    sourceStream.Close();
            //}

            OutputData<UserData> ud = new OutputData<UserData>();

            User updateduser = userRepository.Update(us);

            if (updateduser != null)
            {
                UserData userD = new UserData();

                userD.UserId = updateduser.UserId;

                userD.FirstName = updateduser.FirstName;
                userD.LastName = updateduser.LastName;

                userD.MobileNumber = updateduser.MobileNumber;
                userD.Email = updateduser.Email;

                userD.Country = updateduser.Country;
                userD.State = updateduser.State;
                userD.City = updateduser.City;

                userD.Gender = updateduser.Gender;
                userD.Height = updateduser.Height;
                userD.Weight = updateduser.Weight;
                userD.DOB = updateduser.DOB;
                userD.LifetimePoint = 0;
                userD.GeoPoint = 0;
                userD.Level = 0; ;
                userD.AvgPace = 0;

                userD.Password = "";

                ud.Success = 1;
                ud.Message = "Updated successfully";
                ud.Result = userD;
                return ud;
            }
            else
            {
                ud.Success = 0;
                ud.Message = "Failed to update user";
                ud.Result = null;
                return ud;
            }
        }