예제 #1
0
        /// <summary>
        /// delete assistant
        /// </summary>
        /// <param name="id"> id</param>
        /// <returns>index view</returns>
        // POST: Assistant/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new NotFoundViewResult("AssistantNotFound"));
            }

            var assistant = await _assistantRepository.GetByIdAsync(id.Value);

            if (assistant == null)
            {
                return(new NotFoundViewResult("AssistantNotFound"));
            }

            try
            {
                await _assistantRepository.DeleteAsync(assistant);
            }
            catch (Exception exception)
            {
                ModelState.AddModelError(string.Empty, exception.Message);
            }

            return(RedirectToAction(nameof(Index)));
        }