Beispiel #1
0
        public IActionResult Delete(int?timeEntryID)
        {
            var entry = _timeEntryRepository.GetAllTimeEntries.FirstOrDefault(t => t.TimeEntryID == timeEntryID);

            if (entry != null)
            {
                _timeEntryRepository.DeleteTimeEntry(entry.TimeEntryID);
            }
            return(RedirectToAction("List"));
        }
        async Task ITimeEntryService.DeleteTimeEntry(DeleteTimeEntryCommand command)
        {
            var currentPrincipal = await currentUserResolver.ResolveCurrentClaimsPrincipalAsync();

            await authorizationService.AuthorizeResourceType(currentPrincipal, Operation.Delete, typeof(TimeEntry));

            Check.NotNull(command, errorMessage: "Command can not be null.");
            await validationService.Validate(command);

            var existingTimeEntry = await timeEntryRepository.GetTimeEntryById(command.TimeEntryId);

            if (existingTimeEntry == null)
            {
                return;
            }

            await authorizationService.AuthorizeResource(currentPrincipal, Operation.Delete, existingTimeEntry);

            await timeEntryRepository.DeleteTimeEntry(existingTimeEntry);
        }