Exemplo n.º 1
0
        private static void CreateDefaultPolice(IServiceProvider serviceProvider)
        {
            IPoliceRepository  policeRepository  = serviceProvider.GetService <IPoliceRepository>();
            ICitizenRepository citizenRepository = serviceProvider.GetService <ICitizenRepository>();

            if (!policeRepository.GetAllAsIQueryable().Any())
            {
                if (citizenRepository.GetByName(SHERIFF) == null)
                {
                    Citizen policeman = new Citizen
                    {
                        Name     = SHERIFF,
                        Age      = 35,
                        Password = "******"
                    };

                    citizenRepository.Save(policeman);

                    policeRepository.Save(new Policeman {
                        Citizen   = policeman,
                        Rank      = Rank.Sheriff,
                        StartWork = DateTime.Now,
                        Salary    = 2500
                    });
                }
            }
        }
Exemplo n.º 2
0
        public void Save(TvCelebrityViewModel viewModel)
        {
            var citizen = _citizenRepository.GetByName(viewModel.Citizen.Name);

            var model = _mapper.Map <TvCelebrity>(viewModel);

            model.Citizen = citizen;
            _celebrityRepository.Save(model);
        }
Exemplo n.º 3
0
        public void Save(TvStaffViewModel viewModel)
        {
            var model   = _mapper.Map <TvStaff>(viewModel);
            var citizen = _citizenRepository.GetByName(viewModel.Citizen.Name);

            model.Citizen = citizen;
            model.Channel = _userService.GetUser().TvStaff.Channel;
            _staffRepository.Save(model);
        }
Exemplo n.º 4
0
        public bool Remove(string name)
        {
            var citizen = _citizenRepository.GetByName(name);

            if (citizen == null)
            {
                return(false);
            }

            _citizenRepository.Remove(citizen);

            return(true);
        }
Exemplo n.º 5
0
        public void SaveDirector(TvStaffViewModel viewModel)
        {
            var model = _mapper.Map <TvStaff>(viewModel);

            var citizen = _citizenRepository.GetByName(viewModel.Citizen.Name);

            model.Citizen = citizen;

            var channel = _channelRepository.GetByName(viewModel.Channel.Name);

            model.Channel = channel;

            _staffRepository.Save(model);
        }