public async Task <IActionResult> Get(int id)
        {
            try
            {
                Logger.Info($"Try to get task with {id}");
                JobDetail task = await Unit.Tasks.GetAsync(id);

                if (!resourceAccess.HasRight(GetUserClaims(), task))
                {
                    return(Unauthorized());
                }
                return(Ok(task.Create()));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }
        public async Task <IActionResult> Put(int id, [FromBody] JobDetail jobDetail)
        {
            try
            {
                if (!resourceAccess.HasRight(GetUserClaims(), jobDetail))
                {
                    return(Unauthorized());
                }
                Logger.Info($"Modified task with id {id}");

                await Unit.Tasks.UpdateAsync(jobDetail, id);

                await Unit.SaveAsync();

                return(Ok(jobDetail.Create()));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }
        public async Task <IActionResult> Post([FromBody] JobDetail jobDetail)
        {
            try
            {
                if (!resourceAccess.HasRight(GetUserClaims(), jobDetail))
                {
                    return(Unauthorized());
                }
                //This line will result in an null object reference exception, we cannot access properties of jobDetail.Day because they are null
                //Logger.Info($"Task for employee {jobDetail.Day.Employee.FullName}, day {jobDetail.Day.Date} added with id {jobDetail.Id}");
                await Unit.Tasks.InsertAsync(jobDetail);

                await Unit.SaveAsync();

                Logger.Info($"Task with id {jobDetail.Id} was added");
                return(Ok(jobDetail.Create()));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }