public static DalTag ToDalTag(this ServiceTag tag) { return(new DalTag { ID = tag.ID, Name = tag.Name }); }
public static TagBookListModel ToTagBookListModel(this ServiceTag tag, IEnumerable <BookShortModel> books) { return(new TagBookListModel { Tag = Tag.GetTagModel(tag), Books = books }); }
public static TagModel ToTagModel(this ServiceTag tag, int bookCount) { return(new TagModel { ID = tag.ID, Name = tag.Name, BookCount = bookCount }); }
public ActionResult DeleteObject(int id) { try { ServiceTag tag = service.GetTagById(id); service.RemoveTag(tag); return(RedirectToAction("Index")); } catch (Exception ex) { logger.Error(ex); return(View()); } }
public ActionResult List(int id) { try { int userID = (int?)Profile["ID"] ?? 0; ServiceTag tag = service.GetTagById(id); var books = service.GetTagBooks(tag); List <BookShortModel> list = books.Select(book => Book.GetBookShortModel(book.ID, userID)).ToList(); return(View(tag.ToTagBookListModel(list))); } catch (Exception ex) { logger.Error(ex); return(View("Error")); } }
public TagCsvTest() { service = new ServiceTag(); }
public IEnumerable <ServiceBook> GetTagBooks(ServiceTag tag) { return(unit.Tags.GetBooks(tag.ToDalTag()).Select(e => e.ToServiceBook())); }
public void AddTag(ServiceTag tag) { unit.Tags.Create(tag.ToDalTag()); unit.Save(); }
public void AddBookTag(ServiceBook book, ServiceTag tag) { unit.Books.AddTag(book.ToDalBook(), tag.ToDalTag()); unit.Save(); }
public void RemoveTag(ServiceTag tag) { unit.Tags.Delete(tag.ToDalTag()); unit.Save(); }
public void RemoveBookTag(ServiceBook book, ServiceTag tag) { unit.Books.DeleteTag(book.ToDalBook(), tag.ToDalTag()); unit.Save(); }
public ApiController() { service = new ServiceTag(); }
public static TagModel GetTagModel(ServiceTag tag) { return(tag.ToTagModel(manager.listService.GetTagBooks(tag).Count())); }
public override void ExecuteCmdlet() { if (!string.IsNullOrWhiteSpace(ResourceGroupName) && !string.IsNullOrWhiteSpace(WebAppName)) { if (ShouldProcess(WebAppName, $"Removing Access Restriction Rule from Web App '{WebAppName}'")) { var webApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, WebAppName, SlotName)); SiteConfig siteConfig = webApp.SiteConfig; var accessRestrictionList = TargetScmSite ? siteConfig.ScmIpSecurityRestrictions : siteConfig.IpSecurityRestrictions; IpSecurityRestriction ipSecurityRestriction = null; bool accessRestrictionExists = false; foreach (var accessRestriction in accessRestrictionList) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() == Name.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } else if (!string.IsNullOrWhiteSpace(IpAddress)) { if (!string.IsNullOrWhiteSpace(accessRestriction.IpAddress) && accessRestriction.IpAddress.ToLowerInvariant() == IpAddress.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() == Name.ToLowerInvariant()) { continue; } } ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } else if (!string.IsNullOrWhiteSpace(ServiceTag)) { if (!string.IsNullOrWhiteSpace(accessRestriction.IpAddress) && accessRestriction.IpAddress.ToLowerInvariant() == ServiceTag.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() == Name.ToLowerInvariant()) { continue; } } ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } else if (!string.IsNullOrWhiteSpace(SubnetId) || (!string.IsNullOrWhiteSpace(SubnetName) && !string.IsNullOrWhiteSpace(VirtualNetworkName))) { var subnet = !string.IsNullOrWhiteSpace(SubnetId) ? SubnetId : SubnetName; var subnetResourceId = NetworkClient.ValidateSubnet(subnet, VirtualNetworkName, ResourceGroupName, DefaultContext.Subscription.Id); if (!string.IsNullOrWhiteSpace(accessRestriction.VnetSubnetResourceId) && accessRestriction.VnetSubnetResourceId.ToLowerInvariant() == subnetResourceId.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() == Name.ToLowerInvariant()) { continue; } } ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } } if (accessRestrictionExists) { accessRestrictionList.Remove(ipSecurityRestriction); // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, webApp.Location, WebAppName, SlotName, siteConfig); } if (PassThru) { // Refresh object to get the final state webApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, WebAppName, SlotName)); var accessRestrictionConfig = new PSAccessRestrictionConfig(ResourceGroupName, WebAppName, webApp.SiteConfig, SlotName); WriteObject(accessRestrictionConfig); } } } }