Ejemplo n.º 1
0
        public bool Save(userSecurityAnswerModel _Dto)
        {
            try
            {
                List <SecurityAnswerUserMap> _SecurityAnswers = new List <SecurityAnswerUserMap>();

                List <SecurityQuestionAnswerModel> _userSecurityAnswerModel = new List <SecurityQuestionAnswerModel>();

                if (_Dto.Status == "2")
                {
                    var result = db.SecurityAnswerUserMaps.Where(o => o.UserId == _Dto.Id).ToList();
                    if (result.Count() > 0)
                    {
                        db.SecurityAnswerUserMaps.RemoveRange(result);
                    }
                }

                foreach (var item in _Dto.QuestionsLst)
                {
                    SecurityAnswerUserMap _SecurityAnswer = new SecurityAnswerUserMap();
                    _SecurityAnswer.Id              = Guid.NewGuid();
                    _SecurityAnswer.QuestionId      = item.QuestionId;
                    _SecurityAnswer.Answer          = item.Answer;
                    _SecurityAnswer.DisplayOrder    = item.DisplayOrder;
                    _SecurityAnswer.UserId          = _Dto.Id;
                    _SecurityAnswer.CreatedBy       = _Dto.Id;
                    _SecurityAnswer.LastUpdatedBy   = _Dto.Id;
                    _SecurityAnswer.LastUpdatedDate = DateTime.Now;
                    _SecurityAnswer.CreatedDate     = DateTime.Now;
                    _SecurityAnswer.StatusCode      = EMPConstants.Active;
                    _SecurityAnswers.Add(_SecurityAnswer);
                }

                db.SecurityAnswerUserMaps.AddRange(_SecurityAnswers);

                try
                {
                    db.SaveChanges();
                    db.Dispose();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    ExceptionLogger.LogException(ex.ToString(), "SecurityAnswer/PostSecurityQuestion", Guid.Empty);
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex.ToString(), "SecurityAnswer/PostSecurityQuestion", Guid.Empty);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public async Task <Guid> PostForgotPassword(ForgotPasswordModel _Dto)
        {
            emp_CustomerLoginInformation _CustomerLoginInformation = new emp_CustomerLoginInformation();
            SecurityAnswerUserMap        _SecurityAnswerUserMap    = new SecurityAnswerUserMap();

            var dbresult = await db.emp_CustomerLoginInformation.Where(o => o.CrossLinkUserId == _Dto.CrossLinkUserId).Select(o => new CustomerLoginModel
            {
                CrossLinkUserId = o.CrossLinkUserId,
            }).FirstOrDefaultAsync();

            if (dbresult != null)
            {
                var result = await db.SecurityAnswerUserMaps.Where(o => (o.QuestionId == _SecurityAnswerUserMap.QuestionId) && (o.Answer == _SecurityAnswerUserMap.Answer)).Select(o => new SecurityAnswerUserMap
                {
                    UserId = o.UserId,
                }).FirstOrDefaultAsync();
            }
            return(dbresult.UserId ?? Guid.Empty);
        }