Exemplo n.º 1
0
        public HttpResponseMessage Put([FromBody] HouseDto houseDto)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Missing values"));
            }
            string result = _houseService.Edit(houseDto);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(HouseForEditDto house)
        {
            var result = await _houseService.Edit(house);

            if (result)
            {
                return(Ok("Edit successful"));
            }
            else
            {
                return(BadRequest("Failed to Edit"));
            }
        }
Exemplo n.º 3
0
        public IActionResult Edit(HouseEditViewModel houseVM)
        {
            if (houseVM == null)
            {
                return(NotFound());
            }

            houseVM.House.CategoryId = houseVM.CategoryId;
            houseVM.House.OwnerId    = houseVM.OwnerId;

            if (ModelState.IsValid)
            {
                var house = houseVM.House;

                _houseService.Edit(house);

                TempData.Add("ResultMessage", "House Edited Successfully!");

                return(RedirectToAction("Details", new { id = house.HouseId }));
            }
            houseVM.Owners = GetOwnersList();
            return(View(houseVM));
        }