/// <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));
        }
Пример #2
0
        public void OnPostDelete(string id)
        {
            var house = _houseRepository.Read(id);

            _houseRepository.Delete(house);
            this.Houses = _houseRepository.List().Select(n => new ViewModels.HouseViewModel(n)).ToList();
        }
Пример #3
0
 public ActionResult Delete(int id)
 {
     repository.Delete(id);
     return(Ok(
                new
     {
         mensagem = "Registro removido com sucesso",
         codigo = id
     }
                ));
 }
Пример #4
0
        public IActionResult Delete(int id)
        {
            HouseEntity houseEntityToDelete = _houseRepository.GetSingle(id);

            if (houseEntityToDelete == null)
            {
                return(NotFound());
            }

            _houseRepository.Delete(id);

            return(NoContent());
        }
Пример #5
0
        public IHttpActionResult Delete(int id)
        {
            HouseEntity houseEntityToDelete = _houseRepository.GetSingle(id);

            if (houseEntityToDelete == null)
            {
                return(NotFound());
            }

            _houseRepository.Delete(id);

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #6
0
        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());
        }
Пример #8
0
        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());
 }
Пример #10
0
 public async Task <bool> Delete(House model)
 {
     return(await _houses.Delete(model));
 }
Пример #11
0
        public ActionResult DeleteHouse(int houseId)
        {
            _houseRepository.Delete(houseId);

            return(RedirectToAction("Index", "Home"));
        }