Exemple #1
0
        /// <summary>
        /// Update password of current user
        /// </summary>
        /// <param name="model">It Contains updated password</param>
        /// <returns>SaveResult</returns>
        public SaveResult ChangePassword(PasswordReset model)
        {
            bool   success = false;
            string message = "";

            var userety = _userRepository.GetByEmail(model.Email);

            if (userety != null)
            {
                var passwordHash = SimpleHash.ComputeHash(model.Password, "SHA1", null);
                model.Password = passwordHash;
                model.UserId   = userety.UserId;

                var upety = this.Mapper.CreateUserPasswordEntity(model);
                upety.PasswordDate = DateTime.UtcNow;
                upety.CreatedDate  = DateTime.UtcNow;
                _userRepository.ChangePassword(upety);
                success = true;
            }
            else
            {
                success = false;
                message = "User does not exisst.";
            }

            return(success ? SaveResult.SuccessResult
                : SaveResult.FailureResult(message));
        }
        /// <summary>
        /// Add new Vid
        /// </summary>
        /// <param name="vidModel">This consists of all the required information need to form VID object which is further inserted into the database</param>
        /// <returns>SaveResult</returns>
        public SaveResult AddVid(VIDModel vidModel)
        {
            VID isVidExist = _repository.GetVidByVVID(vidModel.VideoVersion, vidModel.VendorId);
            var listVid    = _repository.GetVIDByVideoVersion(vidModel.VideoVersion);

            if (isVidExist != null)
            {
                string existLocalEdit   = string.IsNullOrEmpty(isVidExist.EditName) || isVidExist.EditName == "No" ? "No" : "Yes";
                string PresentLocalEdit = string.IsNullOrEmpty(vidModel.EditName) || vidModel.EditName == "No" ? "No" : "Yes";
                if (existLocalEdit.Equals(PresentLocalEdit))
                {
                    return(SaveResult.FailureResult("Combination of Video Version, VendorId, LocalEdit is already present"));
                }
            }
            if (listVid != null && listVid.Count > 0)
            {
                var titles = listVid.Select(x => x.TitleName).ToList();
                if (!titles.Contains(vidModel.TitleName))
                {
                    return(SaveResult.FailureResult("Entered video version is already present with titlename" + " " + "'" + titles.FirstOrDefault() + "'"));
                }
            }
            VID vid = Mapper.CreateVidEntity(vidModel);

            _repository.Save(vid);
            return(new SaveResult()
            {
                Success = true, Message = "VID Added successfully"
            });
        }
Exemple #3
0
 public SaveResult ResetPassword(PasswordReset passwordReset)
 {
     passwordReset.Password = SimpleHash.ComputeHash(passwordReset.Password, "SHA1", null);
     if (_accountRepository.ResetPassword(passwordReset))
     {
         return(SaveResult.SuccessResult);
     }
     else
     {
         return(SaveResult.FailureResult("Password has been expired"));
     }
 }
Exemple #4
0
        public SaveResult ForgotPassword(PasswordReset passwordresetModel)
        {
            //in minutes
            int ForgotPasswordInterval = App.Config.ForgotPasswordInterval;

            passwordresetModel.ExpireDatetime = DateTime.UtcNow.AddMinutes(ForgotPasswordInterval);
            passwordresetModel.Token          = Guid.NewGuid().ToString("N");

            var ety = this.Mapper.CreatePasswordResetEntity(passwordresetModel);

            if (_accountRepository.ForgotPassword(ety))
            {
                var model = this.Mapper.CreatePasswordResetModel(ety);
                // CreateForgotPasswordNotification: Insert email into Notification Table
                if (CreateForgotPasswordNotification(model))
                {
                    return(SaveResult.SuccessResult);
                }
            }
            return(SaveResult.FailureResult(""));
        }