Example #1
0
 public DepartmentController(IGirafService giraf,
                             ILoggerFactory loggerFactory,
                             RoleManager <GirafRole> roleManager,
                             IAuthenticationService authentication)
 {
     _giraf          = giraf;
     _giraf._logger  = loggerFactory.CreateLogger("Department");
     _roleManager    = roleManager;
     _authentication = authentication;
 }
Example #2
0
 /// <summary>
 /// Constructor is called by the asp.net runtime.
 /// </summary>
 /// <param name="giraf">A reference to the GirafService.</param>
 /// <param name="roleManager">A reference to the... no, wait, just take a guess, eh?</param>
 /// <param name="loggerFactory">A reference to an implementation of ILoggerFactory. Used to create a logger.</param>
 /// <param name="authentication"></param>
 public WeekTemplateController(IGirafService giraf,
                               RoleManager <GirafRole> roleManager,
                               ILoggerFactory loggerFactory,
                               IAuthenticationService authentication)
 {
     _giraf          = giraf;
     _roleManager    = roleManager;
     _giraf._logger  = loggerFactory.CreateLogger("WeekTemplate");
     _authentication = authentication;
 }
Example #3
0
 public AccountController(
     SignInManager <GirafUser> signInManager,
     ILoggerFactory loggerFactory,
     IGirafService giraf,
     IOptions <JwtConfig> configuration,
     RoleManager <GirafRole> roleManager,
     IAuthenticationService authentication)
 {
     _signInManager  = signInManager;
     _giraf          = giraf;
     _giraf._logger  = loggerFactory.CreateLogger("Account");
     _configuration  = configuration;
     _roleManager    = roleManager;
     _authentication = authentication;
 }
Example #4
0
        /// <summary>
        /// Take pictograms and choices from DTO and add them to weekday object.
        /// </summary>
        /// <returns>True if all pictograms and choices were found and added, and false otherwise.</returns>
        /// <param name="to">Pictograms and choices will be added to this object.</param>
        /// <param name="from">Pictograms and choices will be read from this object.</param>
        private static async Task <bool> AddPictogramsToWeekday(Weekday to, WeekdayDTO from, IGirafService _giraf)
        {
            if (from.Activities != null)
            {
                foreach (var activityDTO in from.Activities)
                {
                    var picto = await _giraf._context.Pictograms
                                .Where(p => p.Id == activityDTO.Pictogram.Id).FirstOrDefaultAsync();

                    if (picto != null)
                    {
                        to.Activities.Add(new Activity(to, picto, activityDTO.Order, activityDTO.State));
                    }
                }
            }
            return(true);
        }
Example #5
0
        /// <summary>
        /// From the given DTO, set the name, thumbnail and days of the given week object.
        /// </summary>
        /// <param name="weekDTO">The DTO from which values are read.</param>
        /// <param name="week">The week object to which values are written.</param>
        /// <param name="_giraf">An instance of the GirafService from which the database will be accessed when reading the DTO.</param>
        /// <returns>MissingProperties if thumbnail is missing.
        /// ResourceNotFound if any pictogram id is invalid.
        /// null otherwise.</returns>
        public static async Task <ErrorResponse> SetWeekFromDTO(WeekBaseDTO weekDTO, WeekBase week, IGirafService _giraf)
        {
            var modelErrorCode = weekDTO.ValidateModel();

            if (modelErrorCode.HasValue)
            {
                return(new ErrorResponse(modelErrorCode.Value));
            }

            week.Name = weekDTO.Name;

            Pictogram thumbnail = _giraf._context.Pictograms
                                  .FirstOrDefault(p => p.Id == weekDTO.Thumbnail.Id);

            if (thumbnail == null)
            {
                return(new ErrorResponse(ErrorCode.MissingProperties, "thumbnail"));
            }

            week.Thumbnail = thumbnail;

            foreach (var day in weekDTO.Days)
            {
                var wkDay = new Weekday(day);
                if (!(await AddPictogramsToWeekday(wkDay, day, _giraf)))
                {
                    return(new ErrorResponse(ErrorCode.ResourceNotFound, "pictogram"));
                }

                week.UpdateDay(wkDay);
            }

            //All week days that were not specified in the new schedule, but existed before
            var toBeDeleted = week.Weekdays.Where(wd => !weekDTO.Days.Any(d => d.Day == wd.Day)).ToList();

            foreach (var deletedDay in toBeDeleted)
            {
                week.Weekdays.Remove(deletedDay);
            }

            return(null);
        }
Example #6
0
 public StatusController(IGirafService giraf)
 {
     _giraf = giraf;
 }
Example #7
0
 public PictogramController(IGirafService girafController, ILoggerFactory lFactory)
 {
     _giraf         = girafController;
     _giraf._logger = lFactory.CreateLogger("Pictogram");
 }
Example #8
0
 public WeekController(IGirafService giraf, ILoggerFactory loggerFactory, IAuthenticationService authentication)
 {
     _giraf          = giraf;
     _giraf._logger  = loggerFactory.CreateLogger("Week");
     _authentication = authentication;
 }
Example #9
0
 public static List <UserNameDTO> FindMembers(IEnumerable <GirafUser> users, RoleManager <GirafRole> roleManager, IGirafService girafService)
 {
     return(new List <UserNameDTO>(
                users.Select(m => new UserNameDTO(
                                 m.UserName,
                                 roleManager.findUserRole(girafService._userManager, m).Result,
                                 m.Id
                                 )
                             )));
 }
Example #10
0
 public LogFilter(IGirafService giraf)
 {
     _giraf = giraf;
 }