public async Task <AddSiteResult> AddNewSite(SiteModel site) { //AddSiteResult result = await this.CanAddSite(); //if (result == AddSiteResult.Ok) //{ // await this.siteRepo.AddAsync(SiteMappingProfile.MapSiteModelToSite(site)); // await this.siteRepo.Commit(); //} if (!string.IsNullOrEmpty(site.Address)) { var shouldDefineSecurityProtocol = ControllerTypeHelper.ShouldDefineSecurityProtocol((ControllerTypeEnum)site.ControllerType); if (shouldDefineSecurityProtocol) { var securityProtocol = SecurityProtocolEnum.Ssl3; var controllerInfo = await this.networkDeviceRepo.GetSingleAsync(s => s.Ipaddress == site.Address); if (controllerInfo != null) { securityProtocol = controllerInfo.UseTls12 ? SecurityProtocolEnum.Tls12 : SecurityProtocolEnum.Ssl3; } site.SecurityProtocol = (byte)securityProtocol; } } // Update NotificationID base on parent's Site/Group await this.AddNewNotification(site); await this.siteRepo.AddAsync(SiteMappingProfile.MapSiteModelToSite(site)); await this.siteRepo.CommitAsync(); return(await Task.FromResult(AddSiteResult.Ok)); }
private IList <SiteModelBase> DoMappingSiteToSiteModelBase(IQueryable <Site> sites) { List <SiteModelBase> result = new List <SiteModelBase>(); foreach (var site in sites) { result.Add(SiteMappingProfile.MapSiteToSiteModelBase(site)); } return(result); }
private List <SiteModel> DoMappingSiteToSiteModel(IEnumerable <Site> sites) { List <SiteModel> result = new List <SiteModel>(); foreach (var site in sites) { result.Add(SiteMappingProfile.MapSiteToSiteModel(site)); } return(result); }
public async Task <bool> UpdateSites(List <SiteModel> sites) { foreach (var site in sites) { var siteEntity = await this.siteRepo.GetSingleAsync(s => site.Id == s.Id); if (siteEntity != null) { SiteMappingProfile.MapSiteModelToExistingSite(site, siteEntity); } } // Attempt to save changes to the database await this.siteRepo.CommitAsync(); return(await Task.FromResult(true)); }