<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Core.DomainModel;
using Core.DomainServices;
using UI.MVC4.Models;

namespace UI.MVC4.Controllers.API
{
    public class OrganizationUnitRightsController : GenericRightsController<OrganizationUnit, OrganizationRight, OrganizationRole>
    {
        private readonly IOrgUnitService _orgUnitService;

        public OrganizationUnitRightsController(IGenericRepository<OrganizationRight> rightRepository, 
            IGenericRepository<OrganizationUnit> objectRepository, IOrgUnitService orgUnitService) : base(rightRepository, objectRepository)
        {
            _orgUnitService = orgUnitService;
        }

        /// <summary>
        /// Returns all colllecteds rights for an organization unit and all sub units
        /// </summary>
        /// <param name="id">Id of the unit</param>
        /// <param name="rights">Routing qualifier</param>
        /// <returns>List of rights</returns>
        public override HttpResponseMessage GetRights(int id, bool? rights)
        {
            try
            {
                var orgUnits = _orgUnitService.GetSubTree(id);

                var theRights = new List<OrganizationRight>();
                foreach (var orgUnit in orgUnits)
                {
                    theRights.AddRange(GetRightsQuery(orgUnit.Id));
                }

                var dtos = AutoMapper.Mapper.Map<ICollection<OrganizationRight>, ICollection<RightOutputDTO>>(theRights);

                return Ok(dtos);
            }
            catch (Exception e)
            {
                return Error(e);
            }
        }
    }
}<commit_msg>Removed obsolete routing qualifier<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Core.DomainModel;
using Core.DomainServices;
using UI.MVC4.Models;

namespace UI.MVC4.Controllers.API
{
    public class OrganizationUnitRightsController : GenericRightsController<OrganizationUnit, OrganizationRight, OrganizationRole>
    {
        private readonly IOrgUnitService _orgUnitService;

        public OrganizationUnitRightsController(IGenericRepository<OrganizationRight> rightRepository, 
            IGenericRepository<OrganizationUnit> objectRepository, IOrgUnitService orgUnitService) : base(rightRepository, objectRepository)
        {
            _orgUnitService = orgUnitService;
        }

        /// <summary>
        /// Returns all colllecteds rights for an organization unit and all sub units
        /// </summary>
        /// <param name="id">Id of the unit</param>
        /// <param name="rights">Routing qualifier</param>
        /// <returns>List of rights</returns>
        public override HttpResponseMessage GetRights(int id)
        {
            try
            {
                var orgUnits = _orgUnitService.GetSubTree(id);

                var theRights = new List<OrganizationRight>();
                foreach (var orgUnit in orgUnits)
                {
                    theRights.AddRange(GetRightsQuery(orgUnit.Id));
                }

                var dtos = AutoMapper.Mapper.Map<ICollection<OrganizationRight>, ICollection<RightOutputDTO>>(theRights);

                return Ok(dtos);
            }
            catch (Exception e)
            {
                return Error(e);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.0858860578299456, 'fraction_numerical': 0.001145147437732608, 'mean_word_length': 2.2776735459662287, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2650432', 'n_tokens_mistral': 906, 'n_tokens_neox': 882, 'n_words': 197}