예제 #1
0
        public async Task <IActionResult> Form(int?id)
        {
            var genres = await _base_repository_genre.GetAll();

            ViewBag.GenreList = genres.OrderBy(x => x.Name).Select(
                t => new SelectListItem
            {
                Value = t.Id.ToString(),
                Text  = t.Name + (t.Active ? "" : " - Inactive")
            });

            if (id != null)
            {
                var model = await _base_repository.GetById(id ?? 0);

                if (model != null)
                {
                    ViewBag.Title = "Edit movie";
                    return(View(model));
                }
            }

            ViewBag.Title = "Create movie";
            return(View());
        }
예제 #2
0
        public async Task <IActionResult> Form(int?id)
        {
            if (id != null)
            {
                var model = await _base_repository.GetById(id ?? 0);

                if (model != null)
                {
                    ViewBag.Title = "Edit genre";
                    return(View(model));
                }
            }
            ViewBag.Title = "Create genre";
            return(View());
        }
예제 #3
0
        public async Task <ActionResult <Event> > Get(int id)
        {
            try
            {
                var result = await _eventRepository.GetById(id);

                if (result != null)
                {
                    return(result);
                }
                return(NotFound());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"{LocalLog}[Get]");
                throw ex;
            }
        }
예제 #4
0
        public async Task <IActionResult> Delete(int id)
        {
            var item = await _base_repository_rental.GetById(id);

            if (item != null)
            {
                await _base_repository_rental.Remove(item);

                return(NoContent());
            }
            return(NoContent());
        }