public IActionResult DeleteConfirmed(int id) { var deleteId = id; var invoice = _ownerService.GetById(deleteId); if (invoice == null) { return(RedirectToAction(nameof(Delete), new { id = deleteId, saveChangesError = true })); } try { _ownerService.Delete(deleteId); _ownerService.Save(); TempData.Add("ResultMessage", "Owner deleted successfully!"); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction(nameof(Delete), new { id = deleteId, saveChangesError = true })); } catch (InvalidOperationException) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction(nameof(Delete), new { id = deleteId, saveChangesError = true })); } return(RedirectToAction(nameof(Index))); }
private Owner deleteOwner() { var id = int.Parse(Question("ID of owner: ")); var toRemove = _ownerService.Delete(id); return(toRemove); }
public ActionResult <Owner> Delete(int id) { Owner owner = _ownerService.Delete(id); if (owner == null) { return(BadRequest("Did not find the Owner")); } return(Ok("The owner with an id of " + id + " has been deleted.")); }
public ActionResult Delete(int id) { Owner owner = _ownerService.Delete(id); if (owner == null) { return(StatusCode(404, "Kunne ikke finde pet id: " + id)); } return(Ok($"Owner med Id: {id} is deleted")); }
public ActionResult <Owner> Delet(int id) { var owner = _ownerServices.Delete(id); if (owner == null) { return(StatusCode(404, "Did not find a pet with Id of" + id)); } return(Ok($"Pet" + id + "was deleted")); }
public ActionResult Delete(int id) { try { return(Ok(_ownerService.Delete(id))); } catch (ArgumentException e) { return(BadRequest(e.Message)); } }
// GET: Owner/Delete/5 public ActionResult Delete(int id) { OwnerDTO ownerDTO = dbService.Delete(id); //db.Owners.Find(id); if (ownerDTO == null) { return(HttpNotFound()); } var model = mapperService.Map <OwnerDTO, OwnerViewModel>(ownerDTO); return(View(model)); }
public ActionResult Delete(int id) { try { _ownerService.Delete(id); return(Ok($"Deleted owner with Id: {id}")); } catch (Exception e) { return(NotFound(e.Message)); } }
private void DeleteOwner() { Console.WriteLine("-Delete-"); Console.WriteLine("Choose id: "); int id; while (!int.TryParse(Console.ReadLine(), out id)) { ConsoleError(); } ownerService.Delete(id); ClearOwnerList(); ShowOwnerListData(ownerService.ReadAll()); }
public ActionResult Deleteacount(int id) { var result = _postservice.GetAll().Data.Where(d => d.WUserId == id).ToList(); foreach (var po in result) { _selectedWorkerService.Delete(po.PostId); } _postservice.DeletebyUser(id); _ownerService.Delete(id); _userservice.Delete(id); return(RedirectToAction("Index", "Home")); }
public ActionResult <Owner> Delete(int id) { try { Owner ownerDeleted = _ownerService.Delete(id); return(Accepted($"Owner with id {ownerDeleted.Id} was deleted.", ownerDeleted)); } catch (KeyNotFoundException e) { return(NotFound(e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public ActionResult <Owner> Delete(int id) { try { var ownerToDelete = _ownerService.Delete(id); if (ownerToDelete == null) { return(NotFound()); } return(Accepted(ownerToDelete)); } catch (System.Exception) { return(StatusCode(500, "Error when deleting owner")); } }
public async Task <object> DeleteOwner(int id) { try { if (await CheckPermissionToDeleteOwner(id)) { Response response = await _service.Delete(id); return(this.SendResponse(response)); } return(Forbid()); } catch (Exception e) { Response.StatusCode = StatusCode(500).StatusCode; return(null); } }
public IActionResult DeleteOwner([FromQuery] int id) { try { var owner = _owner.GetSingle(x => x.Id == id); if (owner == null) { return(_jsonResponse.GenerateJsonResult(0, "Owner is Detail Not Found")); } _owner.Delete(owner); _owner.Save(); return(_jsonResponse.GenerateJsonResult(1, $@"Owner is Deleted")); } catch (Exception ex) { return(_jsonResponse.GenerateJsonResult(0, "UnhandledError")); } }
public async Task <BaseResponses <string> > Handle(DeleteOwnerRequest request, CancellationToken cancellationToken) { BaseResponses <string> responses = null; using (var trx = unitOfWork.BeginTransaction()) { try { var data = await AddressService.Delete(request.Id); unitOfWork.SaveChanges(); responses = new BaseResponses <string>("OK"); } catch (RestException ex) { trx.Rollback(); responses = new BaseResponses <string>(ex.StatusCode, ex.Message); } } return(responses); }
public void Delete(int id) { _OwnerService.Delete(id); }
public ActionResult DeleteOwners(int[] ids) { return(Json(ownerService.Delete(ids))); }
public void Delete(Guid id) { _ownerService.Delete(id); }
public async Task <IActionResult> DeleteOwner(long id) { await _service.Delete(id); return(Ok()); }
public ActionResult <Owner> Delete(int id) { return(_ownerService.Delete(id)); }