private void AddPurchase(int FinalTimeOfPurchase, Enrollment Enrollment, DateTime DateTime) { if (!Repository.ArePurchaseOnThatDate(DateTime, Enrollment)) { Account Account = Repository.GetAnAccount(txtNumberPhone.Text.Replace(" ", "")); Purchase NewPurchase = new Purchase(Enrollment, FinalTimeOfPurchase, DateTime, Account); Repository.AddPurchase(NewPurchase); MessagePurchaseAdded(); } else { SetMessage("Ya hay una compra activa en ese horario."); } }
public void ValidatePurchaseInTheDateNotPurchasesInThatDateInMinutes() { DateTime dateTimeOfPurchase = new DateTime(2019, 4, 20, 13, 20, 0); Purchase Purchase = new Purchase(Enrollment, 30, dateTimeOfPurchase, Account); Repository.AddAccount(Account); Repository.AddEnrollment(Enrollment); Repository.AddPurchase(Purchase); DateTime dateTimeOfQuery = new DateTime(2019, 4, 20, 13, 0, 0); Assert.AreEqual(false, Repository.ArePurchaseOnThatDate(dateTimeOfQuery, Enrollment)); using (var MyContext = new MyContext()) { MyContext.Purchases.Attach(Purchase); MyContext.Enrollments.Attach(Enrollment); MyContext.Accounts.Attach(Account); } }