public bool SaveUserList(ChimpUserListDTO token, out string error) { try { var entityList = ChimpUserListRepository.GetMany(x => x.ApiKey == token.ApiKey && x.Uid == token.Uid).ToList(); if (entityList.Count == 0) { if (!ValidateUserCredentials(token, out error)) { return(false); } var entity = token.Token2UserListEntity(); ChimpUserListRepository.Add(entity); if (!ChimpUserListRepository.UnitOfWork.CommitAndRefreshChanges(out error)) { return(false); } token.ListId = entity.ListId; return(true); } error = "record already exists"; return(false); } catch (Exception exception) { error = string.Format("SaveUserList exception::{0}", FormatError(exception)); Logger.Error("SaveUserList", exception, CommonEnums.LoggerObjectTypes.Mailchimp); return(false); } }
public ChimpUserListDTO GetUserListDto(int userId) { try { var entityList = ChimpUserListRepository.GetMany(x => x.UserId == userId).ToList(); return(entityList.Count > 0 ? entityList[0].Entity2UserListDto() : null); } catch (Exception exc) { Logger.Error("GetUserListDto", exc, CommonEnums.LoggerObjectTypes.Mailchimp); return(null); } }