Beispiel #1
0
        /// <summary>
        /// Configures the report role
        /// </summary>
        /// <param name="configuration">The role configuration</param>
        public void Configure
        (
            ReportRoleConfiguration configuration
        )
        {
            Validate.IsNotNull(configuration);

            if (String.IsNullOrWhiteSpace(configuration.Name))
            {
                throw new ArgumentException
                      (
                          "The report role name is required."
                      );
            }

            if (String.IsNullOrWhiteSpace(configuration.Title))
            {
                throw new ArgumentException
                      (
                          "The report role title is required."
                      );
            }

            this.Name        = configuration.Name;
            this.Title       = configuration.Title;
            this.Description = configuration.Description;

            this.DateModified = DateTime.UtcNow;
            this.Version++;
        }
Beispiel #2
0
        /// <summary>
        /// Constructs the report role with the details
        /// </summary>
        /// <param name="configuration">The role configuration</param>
        public ReportRole
        (
            ReportRoleConfiguration configuration
        )
        {
            this.Id          = Guid.NewGuid();
            this.DateCreated = DateTime.UtcNow;

            Configure(configuration);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new report role
        /// </summary>
        /// <param name="configuration">The role configuration</param>
        /// <returns>The role created</returns>
        public ReportRole CreateRole
        (
            ReportRoleConfiguration configuration
        )
        {
            var role = new ReportRole
                       (
                configuration
                       );

            _roleRepository.AddRole(role);
            _unitOfWork.SaveChanges();

            return(role);
        }
Beispiel #4
0
        /// <summary>
        /// Configures a single report role
        /// </summary>
        /// <param name="roleName">The role name</param>
        /// <param name="configuration">The role configuration</param>
        public void ConfigureRole
        (
            string roleName,
            ReportRoleConfiguration configuration
        )
        {
            var role = _roleRepository.GetRole
                       (
                roleName
                       );

            role.Configure
            (
                configuration
            );

            _roleRepository.UpdateRole(role);
            _unitOfWork.SaveChanges();
        }