public ConsolidatedUserInformationResponseModel CreateConsolidatedUser([FromBody] JObject jmodel) { var Model = new ConsolidatedUserInformationInputModel() { UserAccount = jmodel["user"].ToObject <UserAccountModel>(), UserAddress = jmodel["address"].ToObject <UserAddressModel>(), ContactInfo = jmodel["contactInfo"].ToObject <ContactInfoModel>(), Interests = jmodel["interests"].ToObject <List <InterestModel> >() }; Model.UserAccount = UserAccountService.CreateUserAccount(Model.UserAccount); Model.UserAddress = AddressService.CreateUserAddress(Model.UserAddress); Model.ContactInfo.UserAccountId = Model.UserAccount.Id; Model.ContactInfo.UserAddressId = Model.UserAddress.Id; Model.ContactInfo = ContactInfoService.CreateUserContactInfo(Model.ContactInfo); if (Model.Interests != null) { foreach (var Interest in Model.Interests) { var NewMapping = new InterestUserMapModel { UserAccountId = Model.UserAccount.Id, InterestId = Interest.Id }; InterestService.CreateInterestUserMap(NewMapping); } } Model.Interests = InterestService.GetUserInterests(Model.UserAccount.Id); return(TransformHelpers.UserInputModelToUserResponseModel(Model)); }
internal static ContactInfoService getContact() { if (contactInfoService == null) { contactInfoService = new ContactInfoService(); } return(contactInfoService); }
public JsonResult GetContactInfo(string id) { if (string.IsNullOrEmpty(id)) { return(Json(null)); } var mode = new ContactInfoService().Get(id); return(Json(mode)); }
public static ConsolidatedUserInformationResponseModel UserAccountToConsResModel(UserAccount parentAccount) { return(new ConsolidatedUserInformationResponseModel() { address = AddressService.GetAddressForUser(parentAccount.Id), contactInfo = ContactInfoService.GetUserContactInfo(parentAccount.Id), interests = InterestService.GetUserInterests(parentAccount.Id), user = DtoToUserAccountViewModel(parentAccount) }); }
public ConsolidatedUserInformationResponseModel GetConsolidatedUserInfo(int UserId) { var newModel = new ConsolidatedUserInformationResponseModel(); newModel.user = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(UserId)); newModel.address = AddressService.GetAddressForUser(UserId); newModel.contactInfo.UserAddressId = newModel.address.Id; newModel.contactInfo = ContactInfoService.GetUserContactInfo(UserId); newModel.interests = InterestService.GetUserInterests(UserId); return(newModel); }
internal static MatchedBigLittleParentModel GetMatch(int matchId) { using (var _context = new bbbsDbContext()) { MatchedBigLittleParentModel matchedBLPM = new MatchedBigLittleParentModel(); var matchedUsers = (from ua in _context.UserAccounts from lpm in _context.LittleParentMaps from blpm in _context.BigLittleParentMaps where lpm.Id == blpm.LittleParentMapId && ((blpm.Id == matchId) && (ua.Id == lpm.LittleId || ua.Id == lpm.ParentId || ua.Id == blpm.BigId)) select ua).Distinct().ToList(); if (matchedUsers != null) { matchedBLPM.MatchId = matchId; foreach (var match in matchedUsers) { var newModel = new ConsolidatedUserInformationResponseModel(); newModel.user = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(match.Id)); newModel.address = AddressService.GetAddressForUser(match.Id); newModel.contactInfo.UserAddressId = newModel.address.Id; newModel.contactInfo = ContactInfoService.GetUserContactInfo(match.Id); newModel.interests = InterestService.GetUserInterests(match.Id); switch (match.UserTypeId) { case 1: matchedBLPM.Big = newModel; break; case 2: matchedBLPM.Little = newModel; break; case 3: matchedBLPM.Parent = newModel; break; } } matchedBLPM.sharedInterests = InterestService.GetSharedInterest(matchedBLPM.Big.user.Id, matchedBLPM.Little.user.Id).ToList(); return(matchedBLPM); } else { return(null); } } }
public ConsolidatedUserInformationModel UpdateUserInformation([FromBody] JObject jmodel) { var model = new ConsolidatedUserInformationInputModel() { UserAccount = jmodel["user"].ToObject <UserAccountModel>(), UserAddress = jmodel["address"].ToObject <UserAddressModel>(), ContactInfo = jmodel["contactInfo"].ToObject <ContactInfoModel>(), Interests = jmodel["interests"].ToObject <List <InterestModel> >() }; return(new ConsolidatedUserInformationModel { ContactInfoModel = ContactInfoService.UpdateUserContactInfo(model.ContactInfo), UserAccountModel = UserAccountService.UpdateUserAccount(model.UserAccount), UserAddressModel = AddressService.UpdateUserAddress(model.UserAddress) }); }
public ActionResult ContactInfo(string id) { if (string.IsNullOrEmpty(id)) { return(View(new ContactInfoModel())); } else { var mode = new ContactInfoService().Get(id); if (mode == null) { return(View(new ContactInfoModel())); } else { return(View(mode)); } } }
public void TC03_ReplaceWithNewLink() { ContactInfoService contactInfoService = new ContactInfoService(); DiscussGroupLinkService linkService = new DiscussGroupLinkService(); //检查是否所有链接都已替换成功 Assert.IsTrue(linkService.checkAllProcessed(), "链接没有完全替换成功"); List <ContactInfo> list = contactInfoService.getByStatus(EntityStatus.Processing); Console.WriteLine("获得{0}条处理中的ContactInfo", list.Count); foreach (var info in list) { Console.WriteLine("处理ContactInfo, ID={0}", info.ID); string newString = info.OldValue; List <DiscussGroupLink> links = linkService.getByKey(info.Key); foreach (var link in links) { //类型是讨论组,但是连接是QQ群,更改类型。 if (link.LinkType == "Z" && RegexUtil.getMatchedCount(link.NewLink, RegexUtil.QQQunPattern) > 0) { List <string> httpsList = RegexUtil.getMatchedStrings(newString, RegexUtil.HttpPattern); int httpCount = httpsList.Count(x => string.Equals(x, "http:", StringComparison.InvariantCultureIgnoreCase)); if (httpCount == 1) { newString = newString.Replace("QQ讨论组", "QQ群"); } } newString = newString.Replace(link.OldLink, link.NewLink); } contactInfoService.UpdateNewValue(info.ID, newString); } }
public JsonResult GetContactInfo(string id) { var mode = new ContactInfoService().Get(id); return(Json(mode)); }
static void Main(string[] args) { /* * string fileName = @"C:\Users\lisse\Pictures\google_logo.svg"; * byte[] file = System.IO.File.ReadAllBytes(fileName); * System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName); * Console.WriteLine(fileInfo.Length); */ // Console.WriteLine(string.Join("", file)); // AddressRepository aRepo = new AddressRepository(); // Address address = aRepo.Get(1); /* * FilesRepository fileRepo = new FilesRepository(); * Console.WriteLine(fileRepo.Get(1).FileName); * Files fileWrite = fileRepo.Get(2); * System.IO.File.WriteAllBytes(Path.Combine(@"C:\Users\lisse\Pictures\", fileWrite.FileName + "2"), fileWrite.FileByte); */ /* * string fileName2 = @"C:\Users\lisse\Pictures\google_logo2.svg"; * System.IO.FileInfo fileInfo2 = new System.IO.FileInfo(fileName2); * Files fileTest2 = new Files(); * fileTest2.Name = "test import"; * fileTest2.FileName = fileInfo2.Name; * fileTest2.FileExension = fileInfo2.Extension; * fileTest2.FileByte = System.IO.File.ReadAllBytes(fileName2); * fileTest2.FileSize = fileInfo2.Length; * fileTest2.CreateBy = 1; * Console.WriteLine(fileRepo.Insert(fileTest2)); */ /* * string projectDirectory = @"C:\Users\lisse\Documents\Technofuturtic\Projet"; * string projectFilename = Path.Combine(projectDirectory, "ProjectFile.svg"); * string productFilename = Path.Combine(projectDirectory, "ProductFile.svg"); * byte[] projectByte = System.IO.File.ReadAllBytes(projectFilename); * byte[] productByte = System.IO.File.ReadAllBytes(productFilename); * string projectString = string.Empty; * string productString = string.Empty; * * foreach (byte b in projectByte) * { * projectString = string.Concat(projectString, b.ToString()); * //Console.WriteLine(b.ToString()); * } * * foreach (byte b in productByte) * { * productString = string.Concat(productString, b.ToString()); * //Console.WriteLine(b.ToString()); * } * * Console.WriteLine(projectString); */ /* * // ************ City *********** * CitiesRepository cityR = new CitiesRepository(); * Cities cityId = cityR.Get(1); * IEnumerable<Cities> cityByName = cityR.GetByName("lou"); * IEnumerable<Cities> cityByPostalCode = cityR.GetByPostalCode("7110"); * IEnumerable<Cities> cityByCountry = cityR.GetCityByCountry(21); */ /* * // ************ Role *********** * RoleRepository roleR = new RoleRepository(); * Roles role = roleR.Get(1); */ /* * // ************ Account *********** * AccountRepository accR = new AccountRepository(); * Account account = accR.Get(1); * Account account1 = accR.GetAccountByLogin("dave"); * Account account2 = accR.GetAccountByLogin("davde"); */ /* * // ************ Supplier *********** * SupplierRepository suppR = new SupplierRepository(); * Supplier supplier = suppR.Get(1); */ /* * // ************ Project *********** * ProjectRepository projectR = new ProjectRepository(); * Project project = projectR.Get(1); * IEnumerable<Project> projectAccount = projectR.GetProjectByAccountId(1); * IEnumerable<Project> projectByName = projectR.GetProjectByName("maison"); */ /* * // ************ Category *********** * CategoryRepository catR = new CategoryRepository(); * Category cat = catR.Get(1); */ // ************ ContactInfo *********** ContactInfoRepository ciR = new ContactInfoRepository(); ContactInfo ci = ciR.Get(1); /* * // ************ Product *********** * ProductRepository productR = new ProductRepository(); * Product p1 = productR.Get(1); * IEnumerable<Product> p2 = productR.GetAll(); * IEnumerable<Product> p3 = productR.GetByManufacturer("Buderus"); * IEnumerable<Product> p4 = productR.GetByName("Chaudière"); */ // ************ ProductCategory *********** ProductCategoryRepository pdcR = new ProductCategoryRepository(); IEnumerable <ProductCategory> pdc1 = pdcR.Get(1); // ************ ProjectCategory *********** ProjectCategoryRepository pjcR = new ProjectCategoryRepository(); IEnumerable <ProjectCategory> pjc1 = pjcR.Get(1); CountryService countryService = new CountryService(); CitiesService citiesService = new CitiesService(countryService); AddressService addressService = new AddressService(citiesService); RolesService rolesService = new RolesService(); ContactInfoService contactInfoService = new ContactInfoService(); AccountService accServ = new AccountService(addressService, rolesService, contactInfoService); Console.WriteLine(accServ.Get(1).Address.Street); SupplierService supplierService = new SupplierService(addressService, contactInfoService); BLL.Models.Supplier supplier = supplierService.Get(1); FilesService filesService = new FilesService(); BLL.Models.Files file = filesService.Get(1); CategoryService categoryService = new CategoryService(); ProductCategoryService productCategoryService = new ProductCategoryService(categoryService, filesService); List <BLL.Models.ProductCategory> productCategory = productCategoryService.Get(1); ProductService productService = new ProductService(productCategoryService); ProjectCategoryProductService projectCategoryProductService = new ProjectCategoryProductService(productService, supplierService); ProjectCategoryService projectCategoryService = new ProjectCategoryService(categoryService, filesService, projectCategoryProductService); ProjectService projectService = new ProjectService(addressService, projectCategoryService); BLL.Models.Project project = projectService.Get(1); FilesRepository filesRepository = new FilesRepository(); byte[] fileByte = filesRepository.Download(1); }
public void TC01_BreakDownLinks() { ContactInfoService contactInfoService = new ContactInfoService(); DiscussGroupLinkService linkService = new DiscussGroupLinkService(); //清空DiscussGroupLink表 linkService.DeleleAll(); //获取待处理ContactInfo记录 List <ContactInfo> list = contactInfoService.getByStatus(EntityStatus.Waiting); Console.WriteLine("获得{0}条未处理的ContactInfo", list.Count); foreach (var info in list) { Console.WriteLine("处理ContactInfo, ID={0}", info.ID); //更新:处理中 contactInfoService.UpdateStatus(info.ID, EntityStatus.Processing, "处理中"); List <DiscussGroupLink> links = new List <DiscussGroupLink>(); //获取原字符串中的讨论组 List <string> links1 = RegexUtil.getMatchedStrings(info.OldValue, RegexUtil.QQTaoLunZuPattern); links1.ForEach(x => { if (string.IsNullOrWhiteSpace(x)) { return; } DiscussGroupLink link = new DiscussGroupLink() { Key = info.Key, OldLink = x, LinkType = "Z", Status = EntityStatus.Waiting, Message = "待处理", NewLink = "" }; links.Add(link); }); ////获取原字符串中的QQ群 List <string> links2 = RegexUtil.getMatchedStrings(info.OldValue, RegexUtil.QQQunPattern); links2.ForEach(x => { if (string.IsNullOrWhiteSpace(x)) { return; } DiscussGroupLink link = new DiscussGroupLink() { Key = info.Key, OldLink = x, LinkType = "Q", Status = EntityStatus.Waiting, Message = "待处理", NewLink = "" }; links.Add(link); }); //插入数据库 linkService.BulkInsert(links); } }
public ContactInfoModel CreateUserContactInfo(ContactInfoModel contactInfoModel) { return(ContactInfoService.CreateUserContactInfo(contactInfoModel)); }
public ContactInfoModel GetUserContactInfo(int userId) { return(ContactInfoService.GetUserContactInfo(userId)); }
internal static List <MatchedBigLittleParentModel> GetAllMatches() { using (var _context = new bbbsDbContext()) { var query = (from blpm in _context.BigLittleParentMaps join lpm in _context.LittleParentMaps on blpm.LittleParentMapId equals lpm.Id from ua in _context.UserAccounts where blpm.BigId == ua.Id || lpm.LittleId == ua.Id || lpm.ParentId == ua.Id select new UserAccountWithMatchId { MatchId = blpm.Id, FirstName = ua.FirstName, LastName = ua.LastName, Id = ua.Id, Password = ua.Password, UserName = ua.UserName, UserTypeId = ua.UserTypeId, Age = ua.Age }) .Distinct().ToList(); var matchesQuery = query.GroupBy(key => new { key.MatchId }, model => new UserAccountModel { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, UserName = model.UserName, UserTypeId = model.UserTypeId, Password = model.Password, Age = model.Age, PictureUrl = model.PictureUrl }).ToDictionary(y => y.Key, z => z.ToList()); List <MatchedBigLittleParentModel> matches = new List <MatchedBigLittleParentModel>(); foreach (var key in matchesQuery.Keys) { MatchedBigLittleParentModel currentMatch = new MatchedBigLittleParentModel(); foreach (var match in matchesQuery[key]) { var newModel = new ConsolidatedUserInformationResponseModel(); newModel.user = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(match.Id)); newModel.address = AddressService.GetAddressForUser(match.Id); newModel.contactInfo.UserAddressId = newModel.address.Id; newModel.contactInfo = ContactInfoService.GetUserContactInfo(match.Id); newModel.interests = InterestService.GetUserInterests(match.Id); switch (match.UserTypeId) { case 1: currentMatch.Big = newModel; break; case 2: currentMatch.Little = newModel; break; case 3: currentMatch.Parent = newModel; break; } } currentMatch.sharedInterests = InterestService.GetSharedInterest(currentMatch.Big.user.Id, currentMatch.Little.user.Id).ToList(); currentMatch.MatchId = key.MatchId; matches.Add(currentMatch); } return(matches); } }