Example #1
0
        public async Task <IActionResult> EditMyCinema(CinemaViewModel model)
        {
            var user = await GetCurrentUserAsync();

            var    userId = user?.Id;
            string mail   = user?.Email;

            model.LastModifiedByUserId = userId;
            model.AdminUserId          = userId;

            var cinemaAdded = _cinemaService.EditCinema(model);

            if (cinemaAdded)
            {
                var tblCinema = await _cinemaService.GetCinemaByAdminId(userId);

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

                var listOfAllMovies = _movieService.GetMoviesByCinemaId(tblCinema.CinemaId);
                ViewData["ListOfMovies"] = listOfAllMovies;

                return(View("Index", tblCinema));
            }

            return(BadRequest());
        }
        public async Task <IActionResult> Edit(int id, CinemaViewModel model)
        {
            if (id != model.CinemaId)
            {
                return(NotFound());
            }
            var user = await GetCurrentUserAsync();

            var    userId = user?.Id;
            string mail   = user?.Email;

            model.LastModifiedByUserId = userId;

            var cinemaAdded = _cinemaService.EditCinema(model);

            if (cinemaAdded)
            {
                var listOfAllCinemas = _cinemaService.GetAllCinemas();
                return(View("Index", listOfAllCinemas.ToList()).WithSuccess("Info!", "Cinema was edited successfully!"));
            }

            else
            {
                return(View(model));
            }
        }
Example #3
0
        public IActionResult EditCinema([FromBody] CinemaInfo cinemaInfo, int cinemaId)
        {
            Result result = сinemaService.EditCinema(cinemaId, cinemaInfo);

            if (result.ResultOk)
            {
                return(Ok());
            }
            return(NotFound(result));
        }
        public IActionResult EditCinema([FromBody] CinemaView cinema, int cinemaId)
        {
            if (!_сinemaService.CheckCinemaExists(cinemaId))
            {
                return(NotFound(new Response(ErrorOfCinemaNonexistence)));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(new Response(ModelState)));
            }

            _сinemaService.EditCinema(cinemaId, cinema);

            return(Ok(new Response()));
        }