示例#1
0
        public async Task <ActionResult> Delete(int id, IFormCollection collection)
        {
            try
            {
                // Add delete logic here
                // if (id == null) return NotFound(); //indien nullable id
                var edu = await educationRepo.GetEducationAsync(id);

                if (edu == null)
                {
                    return(NotFound());
                }
                await educationRepo.Delete(edu);

                return(RedirectToAction(nameof(IndexAsync)));
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                var errorvm = new ErrorViewModel();
                errorvm.RequestId      = Convert.ToString(id);
                errorvm.HttpStatuscode = System.Net.HttpStatusCode.BadRequest;
                return(View("~/Views/Shared/_Error.cshtml", errorvm));
            }
        }
 public IActionResult Delete(int id)
 {
     _repo.Delete(id);
     return(Ok());
 }