Ejemplo n.º 1
0
 public static DalTag ToDalTag(this ServiceTag tag)
 {
     return(new DalTag
     {
         ID = tag.ID,
         Name = tag.Name
     });
 }
Ejemplo n.º 2
0
 public static TagBookListModel ToTagBookListModel(this ServiceTag tag, IEnumerable <BookShortModel> books)
 {
     return(new TagBookListModel
     {
         Tag = Tag.GetTagModel(tag),
         Books = books
     });
 }
Ejemplo n.º 3
0
 public static TagModel ToTagModel(this ServiceTag tag, int bookCount)
 {
     return(new TagModel
     {
         ID = tag.ID,
         Name = tag.Name,
         BookCount = bookCount
     });
 }
Ejemplo n.º 4
0
 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());
     }
 }
Ejemplo n.º 5
0
        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"));
            }
        }
Ejemplo n.º 6
0
 public TagCsvTest()
 {
     service = new ServiceTag();
 }
Ejemplo n.º 7
0
 public IEnumerable <ServiceBook> GetTagBooks(ServiceTag tag)
 {
     return(unit.Tags.GetBooks(tag.ToDalTag()).Select(e => e.ToServiceBook()));
 }
Ejemplo n.º 8
0
 public void AddTag(ServiceTag tag)
 {
     unit.Tags.Create(tag.ToDalTag());
     unit.Save();
 }
Ejemplo n.º 9
0
 public void AddBookTag(ServiceBook book, ServiceTag tag)
 {
     unit.Books.AddTag(book.ToDalBook(), tag.ToDalTag());
     unit.Save();
 }
Ejemplo n.º 10
0
 public void RemoveTag(ServiceTag tag)
 {
     unit.Tags.Delete(tag.ToDalTag());
     unit.Save();
 }
Ejemplo n.º 11
0
 public void RemoveBookTag(ServiceBook book, ServiceTag tag)
 {
     unit.Books.DeleteTag(book.ToDalBook(), tag.ToDalTag());
     unit.Save();
 }
Ejemplo n.º 12
0
 public ApiController()
 {
     service = new ServiceTag();
 }
Ejemplo n.º 13
0
 public static TagModel GetTagModel(ServiceTag tag)
 {
     return(tag.ToTagModel(manager.listService.GetTagBooks(tag).Count()));
 }
Ejemplo n.º 14
0
        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);
                    }
                }
            }
        }