/// <summary> /// 新增或修改 /// </summary> /// <param name="dto">实体</param> /// <returns></returns> public HouseDto InsertOrUpdate(HouseDto dto) { if (Get(dto.Id) != null) { _houseRepository.Delete(dto.Id); } var house = _houseRepository.InsertOrUpdate(_mapper.Map <House>(dto)); return(_mapper.Map <HouseDto>(house)); }
public void OnPostDelete(string id) { var house = _houseRepository.Read(id); _houseRepository.Delete(house); this.Houses = _houseRepository.List().Select(n => new ViewModels.HouseViewModel(n)).ToList(); }
public ActionResult Delete(int id) { repository.Delete(id); return(Ok( new { mensagem = "Registro removido com sucesso", codigo = id } )); }
public IActionResult Delete(int id) { HouseEntity houseEntityToDelete = _houseRepository.GetSingle(id); if (houseEntityToDelete == null) { return(NotFound()); } _houseRepository.Delete(id); return(NoContent()); }
public IHttpActionResult Delete(int id) { HouseEntity houseEntityToDelete = _houseRepository.GetSingle(id); if (houseEntityToDelete == null) { return(NotFound()); } _houseRepository.Delete(id); return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult DeleteHome(string id) { int decryptedId = int.Parse(protector.Unprotect(id)); House house = _houseRepository.GetHouse(decryptedId); if (house == null) { ViewBag.ErrorMessage = $"House with id = {id} could not be found"; return(View("NotFound")); } _houseRepository.Delete(decryptedId); return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { var existingHouseEntity = _houseRepository.GetSingle(id); if (existingHouseEntity == null) { return(NotFound()); } _houseRepository.Delete(id); bool result = _houseRepository.Save(); if (!result) { throw new Exception($"something went wrong when deleting the House with id: {id}"); } return(NoContent()); }
public IActionResult Delete(int id) { try { HouseEntity houseEntityToDelete = _houseRepository.GetSingle(id); if (houseEntityToDelete == null) { return(NotFound()); } _houseRepository.Delete(id); return(NoContent()); } catch (Exception exception) { //logg exception or do anything with it return(StatusCode((int)HttpStatusCode.InternalServerError)); } }
public IActionResult Delete(int id) { _houseRepository.Delete(id); _houseRepository.Save(); return(Ok()); }
public async Task <bool> Delete(House model) { return(await _houses.Delete(model)); }
public ActionResult DeleteHouse(int houseId) { _houseRepository.Delete(houseId); return(RedirectToAction("Index", "Home")); }