Esempio n. 1
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (repo.Delete(id))
     {
         return(RedirectToAction("Index"));
     }
     return(HttpNotFound());
 }
Esempio n. 2
0
        public bool RemovePerson(int id)
        {
            Person per = _personRepo.Read(id);

            if (per == null)
            {
                return(false);
            }
            else
            {
                return(_personRepo.Delete(per));
            }
        }
        public async Task <ActionResult> DeletePerson(string name)
        {
            try
            {
                var personToDelete = await _personRepo.GetPersonByName(name);

                if (personToDelete == null)
                {
                    return(NotFound($"There is no person with that name in the database"));
                }

                _personRepo.Delete(personToDelete);

                if (await _personRepo.Save())
                {
                    return(Ok($"You deleted the person: {personToDelete.Name.ToString()} from the database"));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure:{e.Message}"));
            }
            return(BadRequest());
        }
Esempio n. 4
0
 void IPersonManager.Delete(int id)
 {
     _personRepo.Delete(id);
 }
Esempio n. 5
0
 public void Delete(int?id)
 {
     personRepo.Delete(id);
 }
Esempio n. 6
0
 public IActionResult DeleteConfirmed(int id)
 {
     _people.Delete(id);
     return(RedirectToAction("Index"));
 }