public Result UpdateProfile(MemberFrontDto dto, int memberId) { var result = _memberUpdateValidator.ValidateResult(dto); if (!result.Success) { return(result); } var query = _memberRepository.AsNoTracking.Where(x => x.Id == memberId); query.Update(u => new Member { Name = dto.Name, Phone = dto.Phone, AddressLine1 = dto.AddressLine1, AddressLine2 = dto.AddressLine2, City = dto.City, State = dto.State, Degree = dto.Degree, College = dto.College, LastSemMark = dto.LastSemMark, Experience = dto.Experience }); MemberCacheManager.ClearCache(); result.SetSuccess("Your account updated successfully."); return(result); }
public Result Edit(int id, MemberDto dto) { dto.Id = id; var validator = new MemberValidator(_memberRepository); var result = validator.ValidateResult(dto); if (!result.Success) { return(result); } var entity = _memberRepository.AsNoTracking .FirstOrDefault(s => s.Id == dto.Id); if (entity == null) { return(new Result().SetBlankRedirect()); } Mapper.Map <Member>(dto, entity); if (!string.IsNullOrEmpty(dto.Password)) { entity.Salt = SecurityHelper.GenerateSalt(); entity.Password = SecurityHelper.GenerateHash(dto.Password, entity.Salt); } _memberRepository.Update(entity); _unitOfWork.Commit(); MemberCacheManager.ClearCache(); return(result.SetSuccess(Messages.RecordSaved)); }
public Result GuestUpdatePassword(MemberGuestDto dto, int memberId) { var validator = new MemberGuestValidator(); var result = validator.ValidateResult(dto); if (!result.Success) { return(result); } var strSalt = SecurityHelper.GenerateSalt(); var strPassword = SecurityHelper.GenerateHash(dto.Password, strSalt); var query = _memberRepository.AsNoTracking.Where(x => x.Id == memberId); query.Update(u => new Member { Password = strPassword, Salt = strSalt, IsActive = true }); MemberCacheManager.ClearCache(); result.Id = memberId; return(result.SetSuccess(Messages.RecordSaved)); }
public Result Create(MemberDto dto) { var validator = new MemberValidator(_memberRepository); var result = validator.ValidateResult(dto); if (!result.Success) { return(result); } dto.CreatedSource = (int)MemberCreatedSource.Admin; var entity = Mapper.Map <Member>(dto); entity.Salt = SecurityHelper.GenerateSalt(); entity.Password = SecurityHelper.GenerateHash(dto.Password, entity.Salt); entity.IsActive = true; entity.LastLoginAt = DateTime.Now; _memberRepository.Insert(entity); _unitOfWork.Commit(); MemberCacheManager.ClearCache(); result.Id = entity.Id; return(result.SetSuccess(Messages.RecordSaved)); }