コード例 #1
0
        public async Task <IActionResult> AddOrUpdateCalendarEntries([FromBody] CalendarEntryDTO calendarEntry)
        {
            try
            {
                var loggedUser = await _userManager.GetUserAsync(User);

                var newEntry = await _calendarService.AddUpdateCalendarEntry(loggedUser.Id, loggedUser.EmployeeType, calendarEntry);

                return(Ok(newEntry));
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException || ex is AdminRoleRequiredException || ex is ValuesChangedByAnotherUserException)
                {
                    return(BadRequest(new Exception(ex.Message)));
                }

                throw;
            }
        }