コード例 #1
0
        public override void Update(LstPersonnel entity)
        {
            var current = _context.LstPersonnel.AsNoTracking().First(e => e.UserID == entity.UserID);

            if (current.Password != entity.Password)
            {
                entity.Password = HashData.Create(entity.Password, entity.Email);
            }

            var childlist = _context.PersonnelBusinessUser.AsNoTracking().Where(p => p.UserId == entity.UserID &&
                                                                                !entity.PersonnelBusinessUser.Select(a => a.BusinessId).Contains(p.BusinessId)).ToList();

            _context.PersonnelBusinessUser.RemoveRange(childlist);
            var groupchildlist = _context.PersonnelGroupMember.AsNoTracking().Where(p => p.UserId == entity.UserID &&
                                                                                    !entity.PersonnelGroupMembers
                                                                                    .Select(a => a.PersonnelgroupmemberId)
                                                                                    .Contains(p.PersonnelgroupmemberId)).ToList();

            _context.PersonnelGroupMember.RemoveRange(groupchildlist);

            var userTypeList = _context.PersonnelUserType.AsNoTracking().Where(p => p.UserId == entity.UserID &&
                                                                               !entity.PersonnelUserTypes.Select(a => a.PersonnelUserTypeId)
                                                                               .Contains(p.PersonnelUserTypeId)).ToList();

            _context.PersonnelUserType.RemoveRange(userTypeList);

            base.Update(entity);
        }
コード例 #2
0
        public LstPersonnel ValidateLogin(string username, string password)
        {
            password = HashData.Create(password, username);
            var personnel = _context.LstPersonnel
                            .Include(t => t.PersonnelGroupMembers).ThenInclude(t => t.Group)
                            .Include(a => a.Gallery)
                            .Include(a => a.PersonnelBusinessUser)

                            .FirstOrDefault(a => a.Email == username && a.DeletedDate == null);

            if (personnel != null)
            {
                if (personnel.Password == password)
                {
                    if (personnel.IsLocked == false)
                    {
                        personnel.LoginAttempt = 0;
                        _context.SaveChanges();
                    }
                    return(personnel);
                }
                else if (personnel.Password != password)
                {
                    if (personnel.LoginAttempt >= _loginSetting.Value.MaxAttempt)
                    {
                        personnel.IsLocked = true;
                    }
                    else
                    {
                        personnel.LoginAttempt += 1;
                    }
                    _context.SaveChanges();
                }
            }

            return(personnel);
        }
コード例 #3
0
        public String UpdatePassword(ChangePassword changePassword)
        {
            var personnel = All.FirstOrDefault(x => x.Email.Equals(changePassword.Email, StringComparison.InvariantCultureIgnoreCase));

            if (personnel == null)
            {
                return("Email id not found");
            }
            if (!string.IsNullOrEmpty(changePassword.OTP))
            {
                //if (VerifyOtp(changePassword) != "Success") return string.Empty;
            }
            else
            {
                var key = HashData.Create(changePassword.CurrentPassword, changePassword.Email);
                if (personnel.Password != key)
                {
                    return("Current password mismatch ");
                }
            }
            personnel.Password = HashData.Create(changePassword.NewPassword, changePassword.Email);

            return(string.Empty);
        }
コード例 #4
0
 public override void Add(LstPersonnel entity)
 {
     entity.Password = HashData.Create(entity.Password, entity.Email);
     base.Add(entity);
 }