public void TestCreateBusiness() { var a = EntityHelper.GetAccount("first", "lastName"); var b = EntityHelper.GetBusiness("business1", Category.ActiveLife); using (var Scope = new SQLiteDatabaseScope<PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { Session.Transaction.Begin(); IRepository r = new GenericRepository(Session); EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); IDataService ds = new DataService(null, bds, null, null, null, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, new PraLoup.Infrastructure.Logging.Log4NetLogger(), null); ba.CreateBusiness(b, a, Role.BusinessAdmin); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); var b1 = bds.Find(b.Id); Assert.IsNotNull(b1); Assert.AreEqual(b, b1); } } }
public void TestAddNewBusinessUser() { var a = EntityHelper.GetAccount("first", "lastName"); var a2 = EntityHelper.GetAccount("first1", "lastName1"); var b = EntityHelper.GetBusiness("business1", Category.ActiveLife); using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { Session.Transaction.Begin(); IRepository r = new GenericRepository(Session); EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); IDataService ds = new DataService(null, bds, null, null, null, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, new PraLoup.Infrastructure.Logging.Log4NetLogger(), null); ba.CreateBusiness(b, a, Role.BusinessAdmin); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { Session.BeginTransaction(); IRepository r = new GenericRepository(Session); EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); IDataService ds = new DataService(null, bds, null, null, null, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, new PraLoup.Infrastructure.Logging.Log4NetLogger(), null); var b1 = ba.GetBusiness(b.Id); ba.AddBusinessUser(b1, a2, Role.StoreStaff); Session.Transaction.Commit(); } } }
private void addBusinessBtn_Click(object sender, EventArgs e) { BusinessActions businessOP = new BusinessActions(); businessOP.Text = "Create"; businessOP.ShowDialog(); GetBusinessData(); }
public void TestCreatePromotion() { var a = EntityHelper.GetAccount("first", "lastName"); var b = EntityHelper.GetBusiness("business1", Category.ActiveLife); var e = EntityHelper.GetEvent("ev name", "venue name"); var d = EntityHelper.GetDeal("dealname", 10); var p = new Promotion(b, e, d, 100, 5); using (var Scope = new SQLiteDatabaseScope<PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession())); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); b = ba.CreateBusiness(b, a, Role.BusinessAdmin); Assert.IsNotNull(b, "business should be saved succesfully"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession())); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); p = pa.SavePromotion(p); Assert.IsNotNull(p, "promotion should be saved succesfully"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); var p1 = pds.Find(p.Id); Assert.IsNotNull(p1); Assert.AreEqual(p, p1); } } }
public void TestCreatePromotion() { var a = EntityHelper.GetAccount("first", "lastName"); var b = EntityHelper.GetBusiness("business1", Category.ActiveLife); var e = EntityHelper.GetEvent("ev name", "venue name"); var d = EntityHelper.GetDeal("dealname", 10); var p = new Promotion(b, e, d, 100, 5); using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession())); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); b = ba.CreateBusiness(b, a, Role.BusinessAdmin); Assert.IsNotNull(b, "business should be saved succesfully"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Scope.GetSessionFactory().OpenSession())); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); p = pa.SavePromotion(p); Assert.IsNotNull(p, "promotion should be saved succesfully"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); var p1 = pds.Find(p.Id); Assert.IsNotNull(p1); Assert.AreEqual(p, p1); } } }
private void businessEditBtn_Click(object sender, EventArgs e) { try { BusinessActions businessOP = new BusinessActions(); businessOP.EditBusiness(Convert.ToInt32(businessNumber.Text)); businessOP.Text = "Edit"; businessOP.ShowDialog(); GetBusinessData(); } catch {} }
public AccountBase(IDataService dataService, EventActions eventActions, BusinessActions businessActions, PromotionActions promoActions, PromotionInstanceActions promoInstanceActions, ILogger log) { this.DataService = dataService; this.EventActions = eventActions; this.BusinessActions = businessActions; this.PromotionActions = promoActions; this.PromotionInstanceActions = promoInstanceActions; this.Log = log; }
public void TestAcceptDeclinePromotionInstance() { var a = EntityHelper.GetAccount("first", "lastName"); var i1 = EntityHelper.GetAccount("invite1", "lastName"); var i2 = EntityHelper.GetAccount("invite2", "lastName"); var i3 = EntityHelper.GetAccount("invite3", "lastName"); var b = EntityHelper.GetBusiness("business1", Category.ActiveLife); var e = EntityHelper.GetEvent("ev name", "venue name"); var d = EntityHelper.GetDeal("dealname", 10); var p = new Promotion(b, e, d, 100, 5); using (var Scope = new SQLiteDatabaseScope <PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); b = ba.CreateBusiness(b, a, Role.BusinessAdmin); Assert.IsNotNull(b, "business should be saved succesfully"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService <Business, BusinessValidator> bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService <Promotion, PromotionValidator> pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); p = pa.SavePromotion(p); Assert.IsNotNull(p, "promotion should be saved succesfully"); Session.Transaction.Commit(); } IEnumerable <PromotionInstance> promoInstances; using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); var bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); var pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); var pids = new EntityDataService <PromotionInstance, PromotionInstanceValidator>(r, new PromotionInstanceValidator()); IDataService ds = new DataService(null, bds, pds, null, pids, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); PromotionInstanceActions pia = new PromotionInstanceActions(a, ds, Log, null); Session.Transaction.Begin(); promoInstances = pia.CreatePromoInstance(p, new Account[] { i1, i2, i3 }, "going here"); Assert.IsNotNull(promoInstances, "promotion should be saved succesfully"); Assert.AreEqual(3, promoInstances.Count(), "we should get 2 promotion instance"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); var bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); var pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); var pids = new EntityDataService <PromotionInstance, PromotionInstanceValidator>(r, new PromotionInstanceValidator()); IDataService ds = new DataService(null, bds, pds, null, pids, null, null, null, null, new UnitOfWork(Session)); PromotionInstanceActions pia = new PromotionInstanceActions(i1, ds, Log, null); Session.Transaction.Begin(); var pia1 = pia.Accept(promoInstances.First(), "this sound like fun"); Assert.IsNotNull(pia1); Assert.AreEqual(StatusType.Accept, pia1.Status.StatusType); Assert.IsNotNull(pia1.Coupons, "Coupoin should not be null"); Assert.IsNotNull(pia1.Coupons.First().CouponCode, "Coupon code should be generated"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); var bds = new EntityDataService <Business, BusinessValidator>(r, new BusinessValidator()); var pds = new EntityDataService <Promotion, PromotionValidator>(r, new PromotionValidator()); var pids = new EntityDataService <PromotionInstance, PromotionInstanceValidator>(r, new PromotionInstanceValidator()); IDataService ds = new DataService(null, bds, pds, null, pids, null, null, null, null, new UnitOfWork(Session)); PromotionInstanceActions pia = new PromotionInstanceActions(i2, ds, Log, null); Session.Transaction.Begin(); var pia2 = pia.Decline(promoInstances.ElementAt(1), "this sound like fun"); Assert.IsNotNull(pia2); Assert.AreEqual(StatusType.Decline, pia2.Status.StatusType); Assert.IsNull(pia2.Coupons, "Coupoin should not be null"); Session.Transaction.Commit(); } } }
public void TestAcceptDeclinePromotionInstance() { var a = EntityHelper.GetAccount("first", "lastName"); var i1 = EntityHelper.GetAccount("invite1", "lastName"); var i2 = EntityHelper.GetAccount("invite2", "lastName"); var i3 = EntityHelper.GetAccount("invite3", "lastName"); var b = EntityHelper.GetBusiness("business1", Category.ActiveLife); var e = EntityHelper.GetEvent("ev name", "venue name"); var d = EntityHelper.GetDeal("dealname", 10); var p = new Promotion(b, e, d, 100, 5); using (var Scope = new SQLiteDatabaseScope<PraLoupAutoMappingConfiguration>()) { using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); b = ba.CreateBusiness(b, a, Role.BusinessAdmin); Assert.IsNotNull(b, "business should be saved succesfully"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); EntityDataService<Business, BusinessValidator> bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); EntityDataService<Promotion, PromotionValidator> pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); IDataService ds = new DataService(null, bds, pds, null, null, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); Session.Transaction.Begin(); p = pa.SavePromotion(p); Assert.IsNotNull(p, "promotion should be saved succesfully"); Session.Transaction.Commit(); } IEnumerable<PromotionInstance> promoInstances; using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); var bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); var pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); var pids = new EntityDataService<PromotionInstance, PromotionInstanceValidator>(r, new PromotionInstanceValidator()); IDataService ds = new DataService(null, bds, pds, null, pids, null, null, null, null, new UnitOfWork(Session)); BusinessActions ba = new BusinessActions(a, ds, Log, null); PromotionActions pa = new PromotionActions(a, ds, Log, null); PromotionInstanceActions pia = new PromotionInstanceActions(a, ds, Log, null); Session.Transaction.Begin(); promoInstances = pia.CreatePromoInstance(p, new Account[] { i1, i2, i3 }, "going here"); Assert.IsNotNull(promoInstances, "promotion should be saved succesfully"); Assert.AreEqual(3, promoInstances.Count(), "we should get 2 promotion instance"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); var bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); var pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); var pids = new EntityDataService<PromotionInstance, PromotionInstanceValidator>(r, new PromotionInstanceValidator()); IDataService ds = new DataService(null, bds, pds, null, pids, null, null, null, null, new UnitOfWork(Session)); PromotionInstanceActions pia = new PromotionInstanceActions(i1, ds, Log, null); Session.Transaction.Begin(); var pia1 = pia.Accept(promoInstances.First(), "this sound like fun"); Assert.IsNotNull(pia1); Assert.AreEqual(StatusType.Accept, pia1.Status.StatusType); Assert.IsNotNull(pia1.Coupons, "Coupoin should not be null"); Assert.IsNotNull(pia1.Coupons.First().CouponCode, "Coupon code should be generated"); Session.Transaction.Commit(); } using (ISession Session = Scope.OpenSession()) { IRepository r = new GenericRepository(Session); var bds = new EntityDataService<Business, BusinessValidator>(r, new BusinessValidator()); var pds = new EntityDataService<Promotion, PromotionValidator>(r, new PromotionValidator()); var pids = new EntityDataService<PromotionInstance, PromotionInstanceValidator>(r, new PromotionInstanceValidator()); IDataService ds = new DataService(null, bds, pds, null, pids, null, null, null, null, new UnitOfWork(Session)); PromotionInstanceActions pia = new PromotionInstanceActions(i2, ds, Log, null); Session.Transaction.Begin(); var pia2 = pia.Decline(promoInstances.ElementAt(1), "this sound like fun"); Assert.IsNotNull(pia2); Assert.AreEqual(StatusType.Decline, pia2.Status.StatusType); Assert.IsNull(pia2.Coupons, "Coupoin should not be null"); Session.Transaction.Commit(); } } }