public IActionResult Post([FromBody] HallModel model) { try { if (ModelState.IsValid) { model.Id = _hallService.Add(model); if (!model.Id.Equals(Guid.Empty)) { return(Created(string.Empty, model)); } else { return(NoContent()); } } else { return(BadRequest(ModelState)); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Add(Hall hall) { var result = _hallService.Add(hall); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public ActionResult Create([FromJson] HallViewModel hallViewModel) { if (!ModelState.IsValid) { return(View(hallViewModel)); } HallDomainModel hallDomainModel = Mapper.Map <HallViewModel, HallDomainModel>(hallViewModel); _hallService.Add(hallDomainModel); return(RedirectToAction("Details", "Cinema", new { id = hallDomainModel.CinemaId })); }