Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Add(Hall hall)
        {
            var result = _hallService.Add(hall);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
Ejemplo n.º 3
0
        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 }));
        }