public async Task AuctioneerIsNotEditedIfUsernameMatches() { var service = container.Resolve <IAuctioneerService>(); var first = new AuctioneerModel { FirstName = "FirstName", LastName = "LastName", IsAdmin = true, Password = "******", UserName = "******", }; var second = new AuctioneerModel { FirstName = "FirstName", LastName = "LastName", IsAdmin = true, Password = "******", UserName = "******", }; await service.RegisterAuctioneer(first); var secondAuctioneer = await service.RegisterAuctioneer(second); secondAuctioneer.UserName = "******"; var editResult = await service.EditAuctioneer(secondAuctioneer); Assert.IsNull(editResult); await service.RemoveAuctioneer(first); await service.RemoveAuctioneer(second); }
public async Task AuctioneerWithSameUserNameDoesNotRegistered() { var service = container.Resolve <IAuctioneerService>(); var first = new AuctioneerModel { FirstName = "F1", LastName = "L1", IsAdmin = true, Password = "******", UserName = "******", }; var second = new AuctioneerModel { FirstName = "F2", LastName = "L2", IsAdmin = true, Password = "******", UserName = "******", }; var firstResult = await service.RegisterAuctioneer(first); var secondResult = await service.RegisterAuctioneer(second); Assert.IsNotNull(firstResult); Assert.IsNull(secondResult); await service.RemoveAuctioneer(firstResult); }
public async Task <AuctioneerModel> RegisterAuctioneer(AuctioneerModel auctioneerModel) { if (auctioneerModel == null) { throw new ArgumentNullException(nameof(auctioneerModel)); } using (var db = new AuctionContext()) { var found = db.Auctioneers.Any(a => a.UserName.Equals(auctioneerModel.UserName, StringComparison.CurrentCultureIgnoreCase)); if (found) { return(null); } Auctioneer auctioneer = new Auctioneer { FirstName = auctioneerModel.FirstName, LastName = auctioneerModel.LastName, UserName = auctioneerModel.UserName, Password = auctioneerModel.Password, IsAdmin = auctioneerModel.IsAdmin, }; db.Auctioneers.Add(auctioneer); await db.SaveChangesAsync(); auctioneerModel.Id = auctioneer.Id; return(auctioneerModel); } }
AuctioneerModel InitializeAuctioneer(AuctioneerModel auctioneer) { auctioneer.FirstName = Name_textBox.Text; auctioneer.UserName = UserName_textBox.Text; auctioneer.LastName = LastName_textBox.Text; auctioneer.Password = Password_textBox.Text; return(auctioneer); }
public static bool IsEqualTo(this AuctioneerModel @this, Auctioneer auctioneer) { return (@this.FirstName == auctioneer.FirstName && @this.LastName == auctioneer.LastName && @this.UserName == auctioneer.UserName && @this.Password == auctioneer.Password && @this.IsAdmin == auctioneer.IsAdmin); }
public async Task <AuctioneerModel> EditAuctioneer(AuctioneerModel auctioneerModel) { var auctioneer = auctioneers.FirstOrDefault(a => a.Id == auctioneerModel.Id); auctioneer.FirstName = auctioneerModel.FirstName; auctioneer.LastName = auctioneerModel.LastName; auctioneer.Password = auctioneerModel.Password; return(auctioneer); }
private void Users_comboBox_SelectedIndexChanged(object sender, EventArgs e) { RegistrationMode = Users_comboBox.SelectedIndex == 0; selectedAuctioneer = Users_comboBox.SelectedItem as AuctioneerModel; Name_textBox.Text = selectedAuctioneer.FirstName; LastName_textBox.Text = selectedAuctioneer.LastName; UserName_textBox.Text = selectedAuctioneer.UserName; Password_textBox.Text = selectedAuctioneer.Password; RepeatPassword_textBox.Text = selectedAuctioneer.Password; }
public async Task <AuctioneerModel> RegisterAuctioneer(AuctioneerModel auctioneerModel) { if (auctioneers.Any(a => a.UserName == auctioneerModel.UserName)) { return(null); } else { auctioneers.Add(auctioneerModel); return(auctioneerModel); } }
private void LogIn_button_Click(object sender, EventArgs e) { Isvalidinput = Utils.ValidateInput(UserName_textBox, UserName_label); Isvalidinput = Utils.ValidateInput(Password_textBox, Password_label); if (Isvalidinput) { var user = new AuctioneerModel { UserName = UserName_textBox.Text, Password = Password_textBox.Text, }; } }
public async Task <AuctioneerModel> LoginAuctioneer(AuctioneerModel auctioneerModel) { if (auctioneerModel == null) { throw new ArgumentNullException(nameof(auctioneerModel)); } using (var db = new AuctionContext()) { var found = db.Auctioneers.Any(a => a.UserName.Equals(auctioneerModel.UserName, StringComparison.CurrentCultureIgnoreCase) && a.Password == auctioneerModel.Password); return(found ? auctioneerModel : null); } }
public static Auctioneer ToAuctioneer(this AuctioneerModel auctioneer) { if (auctioneer == null) { throw new ArgumentNullException(nameof(auctioneer)); } return(new Auctioneer() { FirstName = auctioneer.FirstName, LastName = auctioneer.LastName, UserName = auctioneer.UserName, Password = auctioneer.Password, IsAdmin = auctioneer.IsAdmin }); }
public static void MapTo(this AuctioneerModel auctioneerModel, Auctioneer auctioneer) { if (auctioneerModel == null) { throw new ArgumentNullException(nameof(auctioneerModel)); } if (auctioneer == null) { throw new ArgumentNullException(nameof(auctioneer)); } auctioneer.FirstName = auctioneerModel.FirstName; auctioneer.LastName = auctioneerModel.LastName; auctioneer.UserName = auctioneerModel.UserName; auctioneer.Password = auctioneerModel.Password; auctioneer.IsAdmin = auctioneerModel.IsAdmin; }
public MainForm(AuctioneerModel auctioneer) { InitializeComponent(); FirstName_label.Text = auctioneer.FirstName; LastName_label.Text = auctioneer.LastName; CenterLabel(FirstName_label); CenterLabel(LastName_label); Admin_Button.Visible = auctioneer.IsAdmin; MenuControlForButton = new Dictionary <Button, UserControl> { // [Auction_button] = new AuctionControl(), [Registration_button] = new AuctionRegistrationControl(), // [Trader_button] = new TraderControl(), [Admin_Button] = new AdminControl(), }; }
public async Task <AuctioneerModel> RemoveAuctioneer(AuctioneerModel auctioneerModel) { if (auctioneerModel == null) { throw new ArgumentNullException(nameof(auctioneerModel)); } using (var db = new AuctionContext()) { var auctioneer = db.Auctioneers.FirstOrDefault(a => a.Id == auctioneerModel.Id || a.UserName.Equals(auctioneerModel.UserName, StringComparison.CurrentCultureIgnoreCase)); if (auctioneer == null) { return(null); } db.Auctioneers.Remove(auctioneer); await db.SaveChangesAsync(); return(auctioneerModel); } }
public async Task AuctioneerEdited() { var service = container.Resolve <IAuctioneerService>(); var auctioneerModel = new AuctioneerModel { FirstName = "FirstName", LastName = "LastName", IsAdmin = true, Password = "******", UserName = "******", }; var registeredAuctioneer = await service.RegisterAuctioneer(auctioneerModel); registeredAuctioneer.FirstName = "Modified Name"; await service.EditAuctioneer(registeredAuctioneer); var auctioneerInDatabase = (await service.GetAuctioneers()).First(); Assert.AreEqual("Modified Name", auctioneerInDatabase.FirstName); }
public async Task AuctioneerRegistered() { var service = container.Resolve <IAuctioneerService>(); var auctioneerModel = new AuctioneerModel { FirstName = "FirstName", LastName = "LastName", IsAdmin = true, Password = "******", UserName = "******", }; var result = await service.RegisterAuctioneer(auctioneerModel); var auctioneer = (await service.GetAuctioneers()).First(); Assert.IsTrue(auctioneerModel.IsEqualTo(auctioneer)); Assert.IsNotNull(result); await service.RemoveAuctioneer(result); }
public async Task <AuctioneerModel> EditAuctioneer(AuctioneerModel auctioneerModel) { if (auctioneerModel == null) { throw new ArgumentNullException(nameof(auctioneerModel)); } using (var db = new AuctionContext()) { var auctioneer = db.Auctioneers.FirstOrDefault(o => o.Id == auctioneerModel.Id); if (auctioneer != null) { auctioneer.FirstName = auctioneerModel.FirstName; auctioneer.LastName = auctioneerModel.LastName; auctioneer.UserName = auctioneerModel.UserName; auctioneer.Password = auctioneerModel.Password; auctioneer.IsAdmin = auctioneerModel.IsAdmin; } await db.SaveChangesAsync(); return(auctioneerModel); } }
public Task <AuctioneerModel> RemoveAuctioneer(AuctioneerModel auctioneerModel) { throw new NotImplementedException(); }
public async Task <AuctioneerModel> LoginAuctioneer(AuctioneerModel auctioneerModel) { throw new NotImplementedException(); }
public static bool IsEqualTo(this Auctioneer @this, AuctioneerModel auctioneer) { return(auctioneer.IsEqualTo(@this)); }