public async Task DeleteAsyncShouldReturnFalse() { var companyRepo = new Repository <Company>(db); var townRepo = new Repository <Town>(db); var townUseFullCategoriesRepo = new Repository <TownUseFullCategory>(db); var useFullcategoryRepo = new Repository <UseFullCategory>(db); var useFullCategoryService = new UseFullCategoryService(useFullcategoryRepo, townRepo, townUseFullCategoriesRepo, companyRepo); var townService = new TownService(townRepo, townUseFullCategoriesRepo, useFullCategoryService, companyRepo); var companyService = new CompanySrvice(companyRepo, townService, useFullCategoryService); await companyService.CreateCompanyAsync(new CompanyInputViewDtoModel { Name = "Test", TownName = "TestTown", Address = "Test 12", CategoryName = "Test Service", Phone = "0000 000 000" }); var isDeleted = await companyService.DeleteAsync(2); Assert.False(isDeleted); }
// GET: Recruitment public ActionResult Index(string key) { if (!string.IsNullOrEmpty(key)) { return(this.Details(key)); } ResultDTO <List <PostInfo> > rs = null; Task t1 = Task.Run(() => { PostService service = new PostService(); rs = service.Get((long)0, 0, "Type='tuyen-dung'", "", ""); }); Task t2 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task.WaitAll(new Task[] { t1, t2 }); if (rs.Code < 0) { _log.Error(rs.Message); } if (rs.Data == null) { rs.Data = new List <PostInfo>(); } return(View(rs.Data)); }
public AddStudentUserControl() { InitializeComponent(); this.Rooms.ItemsSource = RoomService.GetRoomsByCampus(campus).Select(r => r.Number); this.University.ItemsSource = GeneralService.GetUniversities().Select(u => u.Name); this.Town.ItemsSource = TownService.GetTowns().Select(t => t.Name); }
// GET: Home public ActionResult Index() { ResultDTO <ArrayList> rs = null; Task t1 = Task.Run(() => { PostService service = new PostService(); rs = service.GetTopHotAndNew(10, 10); }); Task t2 = Task.Run(() => { ViewData["TownItems"] = new TownService().Get(this.HttpContext); }); Task t3 = Task.Run(() => { ViewData["CountItems"] = new TownService().GetPostsCount(); }); Task.WaitAll(new Task[] { t1, t2, t3 }); if (rs.Code < 0) { _log.Error(rs.Message); return(View(new ArrayList())); } return(View(rs.Data)); }
private void EditTicketForm_Load(object sender, EventArgs e) { string[] towns = TownService.GetTownsNames(); this.townComboBox.Items.AddRange(towns); string townCinema = ticket.Screening.Auditorium.Cinema.Town.Name; this.townComboBox.Text = townCinema; string cinemaName = ticket.Screening.Auditorium.Cinema.Name; this.cinemaComboBox.Text = cinemaName; string movieName = ticket.Screening.Movie.Name + "," + ticket.Screening.Movie.ReleaseYear; this.movieComboBox.Text = movieName; string ticketDate = TicketService.GetTicketDate(ticket.Id); this.dateComboBox.Text = ticketDate; string ticketTime = TicketService.GetTicketTime(ticket.Id); this.timeComboBox.Text = ticketTime; string ticketType = ticket.Type.ToString(); this.typeComboBox.Text = ticketType; string seatNumber = ticket.Seat.Number.ToString(); this.seatComboBox.Text = seatNumber; }
private ActionResult Details(string key) { ResultDTO <PostInfo> rs = null; Task t1 = Task.Run(() => { PostService service = new PostService(); rs = service.Get(key); }); Task t2 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task.WaitAll(new Task[] { t1, t2 }); if (rs.Code < 0) { _log.Error(rs.Message); return(View("Index")); } if (rs.Data == null) { rs.Data = new PostInfo(); } return(View("Details", rs.Data)); }
private ActionResult PostsForTown(string key) { ResultDTO <List <PostInfo> > rs = null; Task t1 = Task.Run(() => { TownService service = new TownService(); rs = service.GetPosts(key); }); Task t2 = Task.Run(() => { TownService tService = new TownService(); ViewData["TownItems"] = tService.Get(this.HttpContext); }); Task.WaitAll(new Task[] { t1, t2 }); if (rs.Code < 0) { _log.Error(rs.Message); } if (rs.Data == null) { rs.Data = new List <PostInfo>(); } return(View("~/Views/Recruitment/Index.cshtml", rs.Data)); }
public static void ValidateTownDoesNotExist(string townName) { if (TownService.IsTownExisting(townName)) { throw new InvalidOperationException(string.Format(Constants.ErrorMessages.TownAlreadyExists, townName)); } }
public MovieForm(Movie movie) { this.imageService = new ImageService(); this.townService = new TownService(); this.cinemaService = new CinemaService(); this.screeningService = new ScreeningService(); InitializeComponent(); if (AuthenticationManager.IsAuthenticated() && !AuthenticationManager.HasSuperRights()) { this.Controls.Add(this.ticketsButton); this.Controls.Add(this.townBox); this.Controls.Add(this.hourBox); this.Controls.Add(this.dateBox); this.Controls.Add(this.cinemaComboBox); } System.Drawing.Image image = imageService.byteArrayToImage(movie.Image.Content); this._movie = movie; this.pictureBox.Image = imageService.ScaleImage(image, 142, 224); this.titleBox.Text = _movie.Name; this.genreBox.Text = string.Join(", ", this._movie.Categories.Select(c => c.Name)); this.lengthBox.Text = _movie.Length.ToString() + " minutes"; this.yearBox.Text = _movie.ReleaseYear.ToString(); this.ratingBox.Text = _movie.Rating.ToString() + " / 10"; this.directorBox.Text = _movie.DirectorName; this.ageRestrictionBox.Text = _movie.AgeRestriction.ToString(); this.castBox.Text = string.Join(",", this._movie.Cast.Select(c => c.Name)); this.synopsisBox.Text = _movie.Synopsis; this.townBox.Text = "Select town"; this.townBox.Items.AddRange(townService.GetTownsNames()); this.FormBorderStyle = FormBorderStyle.None; }
public static void CheckTownExisting(string townName) { if (!TownService.IsTownExisting(townName)) { throw new InvalidOperationException(string.Format(Constants.ErrorMessages.TownDoesntExist, townName)); } }
public void Throw_Exeption_IfUser_IsDeleted() { //Arrange var contextOptions = new DbContextOptionsBuilder <LibrarySystemContext>() .UseInMemoryDatabase(databaseName: "Change_User_Address") .Options; string firstName = "Ivan1", middleName = "Ivanov1", lastName = "Ivanov1", phoneNumber = "1234567899"; DateTime addOnDate = DateTime.Now; bool isDeleted = false; var validationMock = new Mock <CommonValidations>(); using (var actContext = new LibrarySystemContext(contextOptions)) { var unit = new UnitOfWork(actContext); var townService = new TownService(unit, validationMock.Object); var addressService = new AddressService(unit, validationMock.Object); var userService = new UsersServices(unit, validationMock.Object); var town = townService.AddTown("test"); var address = addressService.AddAddress("test address", town); //Act & Assert userService.AddUser(firstName, middleName, lastName, phoneNumber, addOnDate, isDeleted, address); userService.RemoveUser(firstName, middleName, lastName); userService.UpdateUserAddress(firstName, middleName, lastName, 3); } }
private static void ImportAuditorium(AuditoriumDTO auditoriumDto) { string cinemaName = auditoriumDto.CinemaName; InputDataValidator.ValidateStringMaxLength(cinemaName, Constants.MaxCinemaNameLength); string townName = auditoriumDto.CinemaTownName; TownValidator.CheckTownExisting(townName); int townId = TownService.GetTownId(townName); int cinemaId = CinemaService.GetCinemaId(cinemaName, townId); CinemaValidator.CheckCinemaExisting(cinemaName, townId); byte number = auditoriumDto.Number; AuditoriumValidator.ValidateAuditoriumDoesNotExist(number, cinemaId, cinemaName); AuditoriumService.AddAuditorium(number, cinemaId); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.AuditoriumAddedSuccess, number, cinemaName, townName)); }
private static void ImportSeat(SeatDto seatDto) { string cinemaTown = seatDto.CinemaTown; TownValidator.CheckTownExisting(cinemaTown); int townId = TownService.GetTownId(cinemaTown); string cinemaName = seatDto.CinemaName; CinemaValidator.CheckCinemaExisting(cinemaName, townId); int cinemaId = CinemaService.GetCinemaId(cinemaName, townId); byte auditoriumNumber = seatDto.AuditoriumNumber; AuditoriumValidator.CheckAuditoriumExists(auditoriumNumber, cinemaId, cinemaName); int auditoriumId = AuditoriumService.GetAuditoriumId(auditoriumNumber, cinemaId); int row = seatDto.Row; int number = seatDto.Number; SeatValidator.ValidateSeatDoesntExist(number, auditoriumId, auditoriumNumber); SeatService.AddSeat(number, row, auditoriumId); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.SeatAddedSuccess, number, auditoriumNumber, cinemaName, cinemaTown)); }
private void AddGuest(object sender, RoutedEventArgs e) { try { var townName = this.Town.Text.ToString(); var student = RoomService.GetStudentByRoomAndName( Rooms.SelectedItem.ToString(), Student.SelectedItem.ToString()); Guest guest = new Guest { FirstName = this.FirstName.Text ?? "", MiddleName = this.MiddleName.Text ?? "", LastName = this.LastName.Text ?? "", StudentVisited = student, Town = TownService.GetTownByName(townName) }; GuestService.AddGuest(guest); MessageBox.Show($"Added guest {this.FirstName.Text} {this.LastName.Text} to {student.FullName}", "Information", MessageBoxButton.OK, MessageBoxImage.Information); this.Content = new AddGuestUserControl(); } catch (Exception) { MessageBox.Show($"You need to fill all fields", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public static void ImportScreening(ScreeeningDto screeningDto) { byte auditoriumNumber = screeningDto.AuditoriumNumber; string cinemaTown = screeningDto.CinemaTown; TownValidator.CheckTownExisting(cinemaTown); int townId = TownService.GetTownId(cinemaTown); string cinemaName = screeningDto.CinemaName; CinemaValidator.CheckCinemaExisting(cinemaName, townId); int cinemaId = CinemaService.GetCinemaId(cinemaName, townId); AuditoriumValidator.CheckAuditoriumExists(auditoriumNumber, cinemaId, cinemaName); string movieName = screeningDto.MovieName; int movieReleaseYear = screeningDto.MovieReleaseYear; MovieValidator.CheckMovieExists(movieName, movieReleaseYear); int auditoriumId = AuditoriumService.GetAuditoriumId(auditoriumNumber, cinemaId); DateTime date = screeningDto.Date; ScreeningValidator.ValidateScreeningDoesntExist(auditoriumId, date); int movieId = MovieService.GetMovieId(movieName, movieReleaseYear); ScreeningService.AddScreening(auditoriumId, movieId, date); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.ScreeningAddedSuccess, auditoriumNumber, cinemaName)); }
public void Not_Add_IfTown_Exists() { var contextOptions = new DbContextOptionsBuilder <LibrarySystemContext>() .UseInMemoryDatabase(databaseName: "Not_Add_IfTown_Exists") .Options; var validationMock = new Mock <CommonValidations>(); string town1 = "test 1"; string town2 = "test 1"; // Act using (var actContext = new LibrarySystemContext(contextOptions)) { var unit = new UnitOfWork(actContext); var repo = unit.GetRepo <Town>(); var service = new TownService(unit, validationMock.Object); service.AddTown(town1); service.AddTown(town2); } // Assert using (var assertContext = new LibrarySystemContext(contextOptions)) { var unit = new UnitOfWork(assertContext); var repo = unit.GetRepo <Town>(); var service = new TownService(unit, validationMock.Object); int count = assertContext.Towns.Count(); Assert.AreEqual(1, count); Assert.AreEqual(town1, assertContext.Towns.First().TownName); } }
public DataBaseSeeder() { this.countryService = new CountryService(); this.townService = new TownService(); this.hotelService = new HotelService(); this.touristService = new TouristService(); this.voucherService = new VoucherService(); }
public async Task Thing() { var storageService = new StorageService(); var townService = new TownService(storageService); var table = AuthTable("Towns"); await townService.UpdateTurnipPrices("synergy.harmgmail.com", "test", "1.0.0.0.0.0.0.0.0.0.0.0.0.0"); }
public void Throw_WhenStringEmpty() { //Arrange var stubDBContext = new Mock <IOnlineStoreContext>(); var fakeTownService = new TownService(stubDBContext.Object); //Act & Assert Assert.ThrowsException <ArgumentException>(() => fakeTownService.Create(null)); }
public AuditoriumImportService() { this.auditoriumService = new AuditoriumService(); this.auditoriumValidator = new AuditoriumValidator(auditoriumService); this.cinemaService = new CinemaService(); this.cinemaValidator = new CinemaValidator(cinemaService); this.townService = new TownService(); this.townValidator = new TownValidator(townService); }
public ShowScreeningsForm() { this.cinemaService = new CinemaService(); this.townService = new TownService(); this.movieService = new MovieService(); this.screeningService = new ScreeningService(); this._screenings = new List <Screening>(); this._screeningsHolder = new ScreeningsHolder(); InitializeComponent(); }
public TicketForm() { this.cinemaService = new CinemaService(); this.screeningService = new ScreeningService(); this.movieService = new MovieService(); this.townService = new TownService(); this._movies = new List <Movie>(); InitializeComponent(); }
public static void ImportTown(TownDTO townDto) { string townName = townDto.Name; InputDataValidator.ValidateStringMaxLength(townName, Constants.MaxTownNameLength); TownValidator.ValidateTownDoesNotExist(townName); TownService.AddTown(townName); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.TownAddedSuccess, townName)); }
public EditTicketForm(User user, Ticket ticket) { this.user = user; this.ticket = ticket; this.townService = new TownService(); this.cinemaService = new CinemaService(); this.ticketService = new TicketService(); this.movieService = new MovieService(); this.screeningService = new ScreeningService(); this.seatService = new SeatService(); InitializeComponent(); }
public ScreeningImportService() { this.auditoriumService = new AuditoriumService(); this.cinemaService = new CinemaService(); this.auditoriumValidator = new AuditoriumValidator(auditoriumService); this.cinemaValidator = new CinemaValidator(cinemaService); this.movieService = new MovieService(); this.movieValidator = new MovieValidator(movieService); this.townService = new TownService(); this.townValidator = new TownValidator(townService); this.screeningService = new ScreeningService(); this.screeningValidator = new ScreeningValidator(screeningService); }
public CommandDispatcher( UserService userService, AlbumService albumService, PictureService pictureService, TagService tagService, AlbumRoleService albumRoleService, TownService townService) { this.userService = userService; this.albumService = albumService; this.pictureService = pictureService; this.tagService = tagService; this.albumRoleService = albumRoleService; this.townService = townService; }
public void ShowAllTownsInCountryThrowsExceptionWithNoTowns() { Mock <DbSet <Town> > mockSet; Mock <DbSet <Country> > mockSetCountries; SeedDataBase(out mockSet, out mockSetCountries); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Towns).Returns(mockSet.Object); mockContext.Setup(x => x.Countries).Returns(mockSetCountries.Object); var service = new TownService(mockContext.Object); Assert.Throws <InvalidOperationException>(() => service.ShowAllTownsInCountry("Russia")); }
public void GetTownByNameShouldThrowExceptionWithInvalidTown() { Mock <DbSet <Town> > mockSet; Mock <DbSet <Country> > mockSetCountries; SeedDataBase(out mockSet, out mockSetCountries); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Towns).Returns(mockSet.Object); mockContext.Setup(x => x.Countries).Returns(mockSetCountries.Object); var service = new TownService(mockContext.Object); Assert.Throws <ArgumentException>(() => service.GetTownByName("Bulgaria", "Vidin")); }
public void GetTownByNameShouldReturnTown() { Mock <DbSet <Town> > mockSet; Mock <DbSet <Country> > mockSetCountries; SeedDataBase(out mockSet, out mockSetCountries); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Towns).Returns(mockSet.Object); mockContext.Setup(x => x.Countries).Returns(mockSetCountries.Object); var service = new TownService(mockContext.Object); var town = service.GetTownByName("Bulgaria", "Sofia"); Assert.AreEqual("Sofia", town.TownName); }
public async Task CheckIfExistsAsyncShouldReturnFalse() { var townRepo = new Repository <Town>(db); var useFullCategory = new Repository <UseFullCategory>(db); var companyRepo = new Repository <Company>(db); var townUseFullCategoriesRepo = new Repository <TownUseFullCategory>(db); var useFullCategoryService = new UseFullCategoryService(useFullCategory, townRepo, townUseFullCategoriesRepo, companyRepo); var townService = new TownService(townRepo, townUseFullCategoriesRepo, useFullCategoryService, companyRepo); await townService.CreateTownByNameAsync("Test"); var ifExists = await townService.CheckIfExistsAsync("Test1"); Assert.False(ifExists); }