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 }); } } }
public void Save(TvCelebrityViewModel viewModel) { var citizen = _citizenRepository.GetByName(viewModel.Citizen.Name); var model = _mapper.Map <TvCelebrity>(viewModel); model.Citizen = citizen; _celebrityRepository.Save(model); }
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); }
public bool Remove(string name) { var citizen = _citizenRepository.GetByName(name); if (citizen == null) { return(false); } _citizenRepository.Remove(citizen); return(true); }
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); }