예제 #1
0
        public IActionResult Index()
        {
            var model  = _producerService.GetAll();
            var result = _mapper.Map <IEnumerable <Producer>, IEnumerable <ProducerViewModel> >(model);

            return(View(result));
        }
예제 #2
0
        public ViewResult Index()
        {
            var producs = _producerService.GetAll();
            var model   = _mapper.Map <IEnumerable <ProducerViewModel> >(producs);

            return
                (View(model));
        }
예제 #3
0
        public IActionResult Edit(int id)
        {
            var movie         = _movieDbService.GetById(id);
            var producers     = _producerDbService.GetAll()?.OrderBy(x => x.FirstName).ToList();
            var allActors     = _actorDbService.GetAll()?.OrderBy(x => x.FirstName).ToList();
            var actorsInMovie = new List <Actor>();

            if (movie != null)
            {
                actorsInMovie = _movieDbService.GetMovieActors(movie.Id).ToList();
            }

            if (producers == null)
            {
                producers = new List <Producer>();
            }

            if (allActors == null)
            {
                allActors = new List <Actor>();
            }

            MovieViewModel listingResult;

            try
            {
                listingResult = new MovieViewModel()
                {
                    Id                = movie.Id,
                    MovieName         = movie.Name,
                    Plot              = movie.Plot,
                    ReleaseYear       = movie.ReleaseYear,
                    PosterUrl         = movie.PosterUrl,
                    CurrentPoster     = movie.PosterUrl,
                    MovieActors       = actorsInMovie,
                    AllActors         = ProjectToActorCheckboxModelList(allActors, actorsInMovie),
                    Producers         = producers,
                    CurrentProducerId = movie.Producer?.Id ?? 0,
                    PersonViewModel   = new PersonViewModel(_genders)
                };
            }
            catch (Exception ex)
            {
                if (id != 0)
                {
                    return(RedirectToAction("Error", new { message = "Invalid movie request" }));
                }

                listingResult = new MovieViewModel()
                {
                    AllActors       = ProjectToActorCheckboxModelList(allActors, actorsInMovie),
                    Producers       = producers,
                    PersonViewModel = new PersonViewModel(_genders)
                };
            }

            return(View(listingResult));
        }
예제 #4
0
        public IActionResult Create()
        {
            IEnumerable <GroupDrug> groupDrugs = _groupDrugService.GetAll();
            IEnumerable <Producer>  producers  = _producerService.GetAll();

            ViewData["GroupDrugId"] = new SelectList(groupDrugs, "Id", "Name");
            ViewData["ProducerId"]  = new SelectList(producers, "Id", "Name");
            return(View());
        }
        public IActionResult Create()
        {
            var producer        = _producerService.GetAll();
            var productcategory = _productCategoryService.GetAll();
            var supplier        = _supplierService.GetAll();

            ViewBag.CategoryId = new SelectList(productcategory, "Id", "Name");
            ViewBag.ProducerId = new SelectList(producer, "Id", "Name");
            ViewBag.SupplierId = new SelectList(supplier, "Id", "Name");
            return(View());
        }
예제 #6
0
        public IActionResult Get()
        {
            var objs   = producerService.GetAll().ToList();
            var result = mapper.Map <List <ProducerResource> >(objs);

            return(new ObjectResult(result));
        }
예제 #7
0
        public IActionResult Index()
        {
            var producers = _producerDbService.GetAll();

            if (producers == null)
            {
                return(RedirectToAction("Error", "Listing"));
            }

            var listingResult = producers
                                .Select(result => new PersonDetailsViewModel
            {
                Id   = result.Id,
                Name = result.FullName,
                DOB  = result.DOB.ToString("MM/dd/yyyy"),
                Age  = result.Age,
                Sex  = result.Sex.Description,
                Bio  = result.Bio
            })
                                .OrderBy(x => x.Name);

            var model = new ProducersListingViewModel()
            {
                Producers = listingResult
            };

            return(View(model));
        }
        public IActionResult GetAll()
        {
            var result = _producerService.GetAll();

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
예제 #9
0
 public Task ActivateAsync(object parameter)
 {
     _currentEmployee = (EmployeeDTO)parameter;
     CategoryDtos     = _mapper.Map <List <Category>, List <CategoryDTO> >(_categoryService.GetAll());
     CategoryFilterComboBox.ItemsSource = CategoryDtos;
     ProducerDtos = _mapper.Map <List <Producer>, List <ProducerDTO> >(_producerService.GetAll());
     ProducerFilterComboBox.ItemsSource = ProducerDtos;
     UpdateDataGrid();
     return(Task.CompletedTask);
 }
예제 #10
0
        private void UpdateDataGrid()
        {
            ProducerDtos = _mapper.Map <List <Producer>, List <ProducerDTO> >(_producerService.GetAll());

            ProducerDtos.Sort(delegate(ProducerDTO x, ProducerDTO y)
            {
                return(x.Id.CompareTo(y.Id));
            });

            DataGrid.ItemsSource = ProducerDtos;
        }
예제 #11
0
        public ManagerProducerController(IProducerService producerService)
        {
            _producerService = producerService;

            var producer = _producerService.GetAll();

            if (producer != null)
            {
                var producerViewModel = Mapper.Map <IEnumerable <ProducerViewModel> >(producer);

                _listProducerViewModel = producerViewModel.ToList();
            }
        }
예제 #12
0
        public IActionResult Get()
        {
            var list = producerService.GetAll();

            if (list != null)
            {
                return(Ok(list));
            }
            else
            {
                return(NotFound("Empty"));
            }
        }
        public IActionResult AddMovie()
        {
            var actors        = actorService.GetAll();
            var producers     = producerService.GetAll();
            var actorslist    = new List <SelectListItem>();
            var producerslist = new List <SelectListItem>();

            foreach (var a in actors)
            {
                actorslist.Add(new SelectListItem {
                    Text = a.name, Value = a.actorid.ToString()
                });
            }
            foreach (var a in producers)
            {
                producerslist.Add(new SelectListItem {
                    Text = a.name, Value = a.producerid.ToString()
                });
            }
            ViewBag.actors    = actorslist;
            ViewBag.producers = producerslist;
            return(View());
        }
예제 #14
0
파일: CarValidator.cs 프로젝트: PawelPWA/PB
        public CarValidator(IProducerService producerService)
        {
            _producerService = producerService;

            RuleFor(n => n.Name)
            .NotNull().WithMessage("Name can not be null")
            .Length(1, 256).WithMessage("Name lenght has to bo in [1, 255] range");

            RuleFor(n => n.Year)
            .GreaterThanOrEqualTo(1900).WithMessage("Year must be greater than 1900")
            .LessThanOrEqualTo(DateTime.UtcNow.Year).WithMessage($"Year must be lower than {DateTime.UtcNow.Year}");

            var availableProducersIds = _producerService.GetAll().Select(n => n.Id).ToList();

            RuleFor(n => n.ProducerId)
            .Must(n => availableProducersIds.Any(m => m == n)).WithMessage("ProducerId is out of range");
        }
예제 #15
0
 public IActionResult Create()
 {
     ViewData["ProducerModelID"] = new SelectList(_producerService.GetAll(), "Id", "Name").OrderBy(x => x.Text);
     return(View());
 }
        public IActionResult GetAll()
        {
            var res = producerService.GetAll();

            return(View(res));
        }
예제 #17
0
        public ActionResult Edit(Guid id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            var film = _filmService.Find(id);

            if (film == null)
            {
                return(HttpNotFound());
            }
            var movie = _movieService.Find(film.MovieId);

            var movieViewModel = AutoMapper.Mapper.Map <MoviesViewModel>(movie);
            var filmViewModel  = AutoMapper.Mapper.Map <FilmViewModel>(film);

            //Director Start
            var listDirectorMovie  = _directorMovieService.GetIdDirectorByMovieId(movie.Id);
            var listDirector       = _directorService.GetAll();
            var listDirectorSelect = new List <SelectListItem>();

            foreach (var item in listDirector)
            {
                if (listDirectorMovie.Contains(item.Id))
                {
                    listDirectorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameDirector,
                        Selected = true
                    });
                }
                else
                {
                    listDirectorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameDirector,
                        Selected = false
                    });
                }
            }
            //Director End

            //Actor Start
            var listActorMovie  = _actorMovieService.GetIdActorByMovieId(movie.Id);
            var listActor       = _actorService.GetAll();
            var listActorSelect = new List <SelectListItem>();

            foreach (var item in listActor)
            {
                if (listActorMovie.Contains(item.Id))
                {
                    listActorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameActor,
                        Selected = true
                    });
                }
                else
                {
                    listActorSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameActor,
                        Selected = false
                    });
                }
            }
            //Actor End

            //Producer Start
            var listProducerMovie  = _producerMovieService.GetIdProducerByMovieId(movie.Id);
            var listProducer       = _producerService.GetAll();
            var listProducerSelect = new List <SelectListItem>();

            foreach (var item in listProducer)
            {
                if (listProducerMovie.Contains(item.Id))
                {
                    listProducerSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameProducer,
                        Selected = true
                    });
                }
                else
                {
                    listProducerSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameProducer,
                        Selected = false
                    });
                }
            }
            //Producer End

            //Category Start
            var listCategoryMovie  = _categoryMovieService.GetIdCategoryByMovieId(movie.Id);
            var listCategory       = _categorysService.GetAll();
            var listCategorySelect = new List <SelectListItem>();

            foreach (var item in listCategory)
            {
                if (listCategoryMovie.Contains(item.Id))
                {
                    listCategorySelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameCategory,
                        Selected = true
                    });
                }
                else
                {
                    listCategorySelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameCategory,
                        Selected = false
                    });
                }
            }
            //Category End

            //Resolution Start
            var listResolutionMovie  = _resolutionMovieService.GetIdResolutionByMovieId(movie.Id);
            var listResolution       = _resolutionService.GetAll();
            var listResolutionSelect = new List <SelectListItem>();

            foreach (var item in listResolution)
            {
                if (listResolutionMovie.Contains(item.Id))
                {
                    listResolutionSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameResolution,
                        Selected = true
                    });
                }
                else
                {
                    listResolutionSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameResolution,
                        Selected = false
                    });
                }
            }
            //Resolution End

            //Tag Start
            var listTagMovie  = _tagMovieService.GetIdTagByMovieId(movie.Id);
            var listTag       = _tagService.GetAll();
            var listTagSelect = new List <SelectListItem>();

            foreach (var item in listTag)
            {
                if (listResolutionMovie.Contains(item.Id))
                {
                    listTagSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameTag,
                        Selected = true
                    });
                }
                else
                {
                    listTagSelect.Add(new SelectListItem()
                    {
                        Value    = item.Id.ToString(),
                        Text     = item.NameTag,
                        Selected = false
                    });
                }
            }
            //Tag End


            ViewBag.ListDirector   = listDirectorSelect;
            ViewBag.ListActor      = listActorSelect;
            ViewBag.ListProducer   = listProducerSelect;
            ViewBag.ListCategory   = listCategorySelect;
            ViewBag.ListResolution = listResolutionSelect;
            ViewBag.ListTag        = listTagSelect;


            var model = new FeatureFilmViewModel()
            {
                MoviesViewModel = movieViewModel,
                FilmViewModel   = filmViewModel
            };

            return(View("_Edit", model));
        }
예제 #18
0
        public IActionResult List()
        {
            var allObj = _producerService.GetAll();

            return(Json(new { data = allObj }));
        }
        public IActionResult GetAll()
        {
            var response = _service.GetAll();

            return(Ok(response));
        }