Ejemplo n.º 1
0
 public ActionResult Create(PublicHouseViewModel publicHouse)
 {
     if (ModelState.IsValid)
     {
         _publicHouseService.Create(publicHouse);
         return(RedirectToAction("Index"));
     }
     return(View(publicHouse));
 }
        public async Task <IActionResult> Create([FromBody] CreatePublicHouseViewModel itemVM)
        {
            if (itemVM == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            int newItemId = await _service.Create(itemVM);

            itemVM.Id = newItemId;
            return(Ok(itemVM));
        }