public void DepartmentByIdTest() { //Arrange string departmentId = string.Empty; using (IDataContextAsync context = new PrimeActs.Data.Contexts.PAndIContext() as IDataContextAsync) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Department> departmentRepository = new Repository <Department>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IDepartmentService departmentService = new DepartmentService(departmentRepository, cache); var department = CreateDepartment(); departmentId = department.DepartmentID.ToString(); departmentService.Insert(department); unitOfWork.SaveChanges(); departmentService.RefreshCache(); } //Act using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Department> departmentRepository = new Repository <Department>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IDepartmentService departmentService = new DepartmentService(departmentRepository, cache); var department = departmentService.DepartmentById(Guid.Parse(departmentId)); //Assert Assert.AreEqual(department.DepartmentID.ToString(), departmentId); } }
public void CreateProduceTest() { string guid = string.Empty; using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Produce> produceRepository = new Repository <Produce>(context, unitOfWork); var produce = CreateProduce(); guid = produce.ProduceID.ToString(); produceRepository.Insert(produce); unitOfWork.SaveChanges(); } using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Produce> produceRepository = new Repository <Produce>(context, unitOfWork); var produce = produceRepository.Find(Guid.Parse(guid)); Assert.AreEqual(produce.ProduceName, guid.Replace("-", "")); Assert.AreEqual(produce.ProduceID.ToString(), guid); } }
public void ProduceByIdTest() { //Arrange string produceId = string.Empty; using (IDataContextAsync context = new PrimeActs.Data.Contexts.PAndIContext() as IDataContextAsync) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Produce> produceRepository = new Repository <Produce>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IProduceService produceService = new ProduceService(produceRepository, cache); var produce = CreateProduce(); produceId = produce.ProduceID.ToString(); produceService.Insert(produce); unitOfWork.SaveChanges(); produceService.RefreshCache(); } //Act using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Produce> produceRepository = new Repository <Produce>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IProduceService produceService = new ProduceService(produceRepository, cache); var produce = produceService.ProduceById(Guid.Parse(produceId)); //Assert Assert.AreEqual(produce.ProduceID.ToString(), produceId); } }
public void CreateConsignmentItemTest() { var guid = string.Empty; using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <ConsignmentItem> consignmentItemRepository = new Repository <ConsignmentItem>(context, unitOfWork); var consignmentItem = CreateConsignmentItem(); guid = consignmentItem.ConsignmentItemID.ToString(); consignmentItemRepository.Insert(consignmentItem); unitOfWork.SaveChanges(); } using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <ConsignmentItem> consignmentItemRepository = new Repository <ConsignmentItem>(context, unitOfWork); var consignmentItem = consignmentItemRepository.Find(Guid.Parse(guid)); Assert.AreEqual(consignmentItem.ConsignmentItemID.ToString(), guid); } }
public void CreateDepartmentTest() { string guid = string.Empty; using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Department> departmentRepository = new Repository <Department>(context, unitOfWork); var department = CreateDepartment(); guid = department.DepartmentID.ToString(); departmentRepository.Insert(department); unitOfWork.SaveChanges(); } using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Department> departmentRepository = new Repository <Department>(context, unitOfWork); var department = departmentRepository.Find(Guid.Parse(guid)); Assert.AreEqual(department.DepartmentName, guid.Replace("-", "")); Assert.AreEqual(department.DepartmentID.ToString(), guid); } }
public void DeleteAll() { using (var context = new PAndIContext()) { context.Database.ExecuteSqlCommand("Delete from tblTempBankStatementItemNominalLedgerEntry"); } }
//AK: commented out - as not used at all - 11/01/2017 //public List<ProduceQuantityForTicket> GetProduceQuantityForTicket(Guid userDivisionID, int numberOfDays = 7) //{ // using (var context = new PAndIContext()) // { // var userdivisionidParameter = new SqlParameter("@DivisionID", userDivisionID); // var numerOfDaysParameter = new SqlParameter("@NumberOfDays", numberOfDays); // return context.Database.SqlQuery<ProduceQuantityForTicket>(produceQuantityForDivisionQuery, userdivisionidParameter, numerOfDaysParameter).ToList(); // } //} public List <ProduceQuantityForTicket> PopulateStockLevels(Guid departmentID, int numberOfDays = 2) { using (var context = new PAndIContext()) { var userdepartmentID = new SqlParameter("@DepartmentID", departmentID); var numerOfDaysParameter = new SqlParameter("@NumberOfDays", numberOfDays); var recordsReturned = context.Database.SqlQuery <ProduceQuantityForTicket>(sqlStockBoard, userdepartmentID, numerOfDaysParameter).ToList(); return(recordsReturned); } }
public List <DailySalesReport> TicketItemsForDailySalesReports(DateTime startDateTime) { var nextDay = startDateTime.AddDays(1); //return results; DateTime endDate = startDateTime.AddDays(1); string qry = "select * from tblTicketItem INNER JOIN tblTicket ON tblTicketItem.TicketID = tblTicket.TicketID WHERE (tblTicket.TicketDate >= @p0 AND tblTicket.TicketDate < @p1)"; string qry2 = "select * from tblTicketItem WHERE (tblTicketItem.CreatedDate >= '2016/06/14' and tblTicketItem.CreatedDate < '2016/06/15' AND IsCashSale = '1')"; string qrytest = "select * from tblTicketItem WHERE (tblTicketItem.TicketItemID = '00760000-0000-0006-8307-508173720759')"; var @p0 = String.Format("{0:yyyy/MM/dd}", startDateTime); var @p1 = String.Format("{0:yyyy/MM/dd}", endDate); // changed to use tblUser instead of ApplicationUser // string dailySalesQuery = @"SELECT tblTicket.TicketReference, tblTicket.TicketDate, tblTicket.IsCashSale, tblTicketItem.TicketItemDescription, tblTicketItem.TicketItemQuantity, // tblTicketItem.TicketItemTotalPrice, tblTicketItem.PorterageValue, tblConsignment.ConsignmentReference, tblConsignmentItem.PackSize, // tblCustomerDepartment.CustomerDepartmentName, tblCustomer.CustomerCompanyName, tblConsignmentItem.Brand, tblConsignmentItem.PackType, // tblTicket.Handling, tblApplicationUser.Firstname, tblApplicationUser.Lastname, tblApplicationUser.Nickname //FROM tblTicket INNER JOIN // tblTicketItem ON tblTicket.TicketID = tblTicketItem.TicketID INNER JOIN // tblConsignmentItem ON tblTicketItem.ConsignmentItemID = tblConsignmentItem.ConsignmentItemID INNER JOIN // tblConsignment ON tblConsignmentItem.ConsignmentID = tblConsignment.ConsignmentID INNER JOIN // tblCustomerDepartment ON tblTicket.CustomerDepartmentID = tblCustomerDepartment.CustomerDepartmentID INNER JOIN // tblCustomer ON tblCustomerDepartment.CustomerID = tblCustomer.CustomerID LEFT JOIN // tblApplicationUser ON tblTicket.SalesPersonUserID = tblApplicationUser.ApplicationUserId //WHERE (tblTicket.TicketDate >= @p0) AND (tblTicket.TicketDate < @p1) //ORDER BY tblTicket.TicketReference, tblTicketItem.TicketItemID"; string dailySalesQuery = @"SELECT tblTicket.TicketReference, tblTicket.TicketDate, tblTicket.IsCashSale, tblTicketItem.TicketItemDescription, tblTicketItem.TicketItemQuantity, tblTicketItem.TicketItemTotalPrice, tblTicketItem.PorterageValue, tblConsignment.ConsignmentReference, tblConsignmentItem.PackSize, tblCustomerDepartment.CustomerDepartmentName, tblCustomer.CustomerCompanyName, tblConsignmentItem.Brand, tblConsignmentItem.PackType, tblTicket.Handling, tblUser.Firstname, tblUser.Lastname, tblUser.Nickname, tblDepartment.DepartmentCode, tblProduce.ProduceName FROM tblTicket INNER JOIN tblTicketItem ON tblTicket.TicketID = tblTicketItem.TicketID INNER JOIN tblConsignmentItem ON tblTicketItem.ConsignmentItemID = tblConsignmentItem.ConsignmentItemID INNER JOIN tblConsignment ON tblConsignmentItem.ConsignmentID = tblConsignment.ConsignmentID INNER JOIN tblCustomerDepartment ON tblTicket.CustomerDepartmentID = tblCustomerDepartment.CustomerDepartmentID INNER JOIN tblCustomer ON tblCustomerDepartment.CustomerID = tblCustomer.CustomerID INNER JOIN tblDepartment ON tblConsignmentItem.DepartmentID = tblDepartment.DepartmentID INNER JOIN tblProduce ON tblConsignmentItem.ProduceID = tblProduce.ProduceID LEFT JOIN tblUser ON tblTicket.SalesPersonUserID = tblUser.UserID WHERE (tblTicket.TicketDate >= @p0 ) AND (tblTicket.TicketDate < @p1) ORDER BY tblTicket.TicketReference, tblTicketItem.TicketItemID"; List <DailySalesReport> dailySales; using (var context = new PAndIContext()) { dailySales = context.Database.SqlQuery <DailySalesReport>(dailySalesQuery, startDateTime, endDate).ToList(); } return(dailySales); }
public void GetAllTicketsTest() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Ticket> ticketRepository = new Repository <Ticket>(context, unitOfWork); ITicketService ticketService = new TicketService(ticketRepository); var ticketList = ticketService.GetAllTickets(); Assert.Greater(ticketList.Count, 0); } }
public void GetAllConsignmentsTest() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Consignment> consignmentRepository = new Repository <Consignment>(context, unitOfWork); IConsignmentService consignmentService = new ConsignmentService(consignmentRepository); var consignmentList = consignmentService.GetAllConsignments(); Assert.Greater(consignmentList.Count, 0); } }
public void ConsignmentByRefTest() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Consignment> consignmentRepository = new Repository <Consignment>(context, unitOfWork); IConsignmentService consignmentService = new ConsignmentService(consignmentRepository); ; var consignment = consignmentService.ConsignmentByRef("R123456"); Assert.AreEqual(consignment.ConsignmentReference, "R123456"); } }
public void GetAllProduceTest() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Produce> produceRepository = new Repository <Produce>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IProduceService produceService = new ProduceService(produceRepository, cache); var produceList = produceService.GetAllProduces(); Assert.Greater(produceList.Count, 0); } }
public List <ProduceQuantityForTicket> GetProduceQuantityForPurchaseInvoice(string produceCode, string consignmentReference, Guid?userDivisionID, int numberOfDays = 7) { using (var context = new PAndIContext()) { var produceCodeParameter = new SqlParameter("@produceCode", string.Format("{0}{1}", produceCode, "%")); var consignmentReferenceParameter = new SqlParameter("@consignmentReference", string.Format("{0}{1}", consignmentReference, consignmentReference.EndsWith("%") ? "" : "%")); var userdivisionidParameter = new SqlParameter("@DivisionID", userDivisionID); var numerOfDaysParameter = new SqlParameter("@NumberOfDays", numberOfDays); var recordsReturned = context.Database.SqlQuery <ProduceQuantityForTicket>(sqlQueryPurchaseInvoice, produceCodeParameter, consignmentReferenceParameter, userdivisionidParameter, numerOfDaysParameter).ToList(); return(recordsReturned); } }
public void GetAllDepartmentTest() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Department> departmentRepository = new Repository <Department>(context, unitOfWork); ICache cache = Cache.Get(CacheType.Memory); IDepartmentService departmentService = new DepartmentService(departmentRepository, cache); var departmentList = departmentService.GetAllDepartments(); Assert.Greater(departmentList.Count, 0); } }
public void TicketByRefTest() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Ticket> ticketRepository = new Repository <Ticket>(context, unitOfWork); ITicketService ticketService = new TicketService(ticketRepository); ; var ticket = ticketService.TicketByRef("AS45454"); Assert.AreEqual(ticket.TicketReference, "AS45454"); } }
public void ConsignmentItemByConsignmentIDTest() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <ConsignmentItem> consignmentItemRepository = new Repository <ConsignmentItem>(context, unitOfWork); IConsignmentItemService consignmentItemService = new ConsignmentItemService(consignmentItemRepository); var guid = Guid.Parse("BBD967D8-3200-47DB-8352-E04362C5B394"); var consignmentItems = consignmentItemService.ConsignmentItemsByConsignmentID(guid); Assert.AreEqual(consignmentItems.Count, 2); } }
public void GetAllCustomerDepartmentContactsTest(string customerDepartmentId) { using (IDataContextAsync context = new PAndIContext()) { using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { var cache = new MemoryCache(); IRepositoryAsync <Contact> contactsRepository = new Repository <Contact>(context, unitOfWork); IContactService contactsService = new ContactService(contactsRepository, cache); var contacts = contactsService.GetAllCustomerDepartmentContacts(Guid.Parse(customerDepartmentId)); Assert.That(contacts.Count, Is.GreaterThan(0)); } } }
public void TestMethod1() { using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <SetupLocal> setupLocalRepository = new Repository <SetupLocal>(context, unitOfWork); IRepositoryAsync <SetupGlobal> setupGlobalRepository = new Repository <SetupGlobal>(context, unitOfWork); ISetupLocalService localService = new SetupLocalService(setupLocalRepository); ISetupGlobalService globalService = new SetupGlobalService(setupGlobalRepository); var findTest = localService.Find("DailySalesTemplate"); Assert.AreEqual(findTest.SetupName, "DailySalesTemplate"); var smtpServerFindTest = localService.Find("SMTPServerURL"); var globaltest = globalService.GetAllSetupValuesBySetupName("MaxAccountingPeriod"); Assert.AreEqual(globaltest[0].SetupValueInt, 12); } }
public void TicketByIdTest() { //Arrange var ticketID = string.Empty; using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Ticket> ticketRepository = new Repository <Ticket>(context, unitOfWork); ITicketService ticketService = new TicketService(ticketRepository); var ticket = CreateTicket(); ticketID = ticket.TicketID.ToString(); ticketService.Insert(ticket); unitOfWork.SaveChanges(); } }
public void ConsignmentByIdTest() { //Arrange var consignmentID = string.Empty; using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Consignment> consignmentRepository = new Repository <Consignment>(context, unitOfWork); IConsignmentService consignmentService = new ConsignmentService(consignmentRepository); var consignment = CreateConsignment(); consignmentID = consignment.ConsignmentID.ToString(); consignmentService.Insert(consignment); unitOfWork.SaveChanges(); } }
public void CreateConsignmentTest() { var guid = string.Empty; using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Consignment> consignmentRepository = new Repository <Consignment>(context, unitOfWork); var consignment = CreateConsignment(); guid = consignment.ConsignmentID.ToString(); consignmentRepository.Insert(consignment); unitOfWork.SaveChanges(); } using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Consignment> consignmentRepository = new Repository <Consignment>(context, unitOfWork); var consignment = consignmentRepository.Find(Guid.Parse(guid)); //Assert.AreEqual(consignment.ConsignmentReference, guid.Replace("-", "")); Assert.AreEqual(consignment.ConsignmentID.ToString(), guid); } }
public void CreateTicketTest() { var guid = string.Empty; using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Ticket> ticketRepository = new Repository <Ticket>(context, unitOfWork); var ticket = CreateTicket(); guid = ticket.TicketID.ToString(); ticketRepository.Insert(ticket); unitOfWork.SaveChanges(); } using (IDataContextAsync context = new PAndIContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Ticket> ticketRepository = new Repository <Ticket>(context, unitOfWork); var ticket = ticketRepository.Find(Guid.Parse(guid)); //Assert.AreEqual(ticket.TicketReference, guid.Replace("-", "")); Assert.AreEqual(ticket.TicketID.ToString(), guid); } }
public List <vwStockBoard> GetStockBoardProducesfromDB() { Guid departmentID = Guid.Empty; Guid produceGroupID = Guid.Empty; Guid mystockboardID = Guid.Parse("D9BF0DFD-9679-4A51-B73C-4D85E793B39B"); StockBoardModel mystockboard = new StockBoardModel(); List <vwStockBoard> Results = new List <vwStockBoard>(); /*******************************************************/ //Starting the group feeds i.e. selection of multiple departments to determine results returned. List <vwStockBoard> DepartmentResultsFeed = new List <vwStockBoard>(); List <Department> departmentFeeds = new List <Department>(); /*******************************************************/ /*******************************************************/ //Starting the group feeds i.e. selection of multiple produce groups to determine results returned. List <vwStockBoard> produceGroupResultsFeed = new List <vwStockBoard>(); List <ProduceGroup> produceGroupfeeds = new List <ProduceGroup>(); /*******************************************************/ var stockBoardIDparameter = new SqlParameter("@StockboardID", mystockboardID); using (var contextvwStockBoard = new PAndIContext()) { if (departmentID != Guid.Empty) { Results = contextvwStockBoard.Database.SqlQuery <vwStockBoard>("Select * from vwStockBoard where DepartmentID = '76000300-0000-0070-9304-000068336078' order by producename asc").ToList(); } if (produceGroupID != Guid.Empty) { Results = contextvwStockBoard.Database.SqlQuery <vwStockBoard>("Select * from vwStockBoard where ProduceGroupID = '76002000-0000-0070-9304-000068336078' order by producename asc").ToList(); } if (mystockboardID != Guid.Empty) { string sqlQueryString = "Select * from vwStockBoard where StockboardID=@StockboardID order by producename asc"; Results = contextvwStockBoard.Database.SqlQuery <vwStockBoard>(sqlQueryString, stockBoardIDparameter).ToList(); } /************************/ //Getting a list of departments - in this case one is hard coded but could be more; but needs to be passed from the page somehow departmentFeeds.Add(new Department { DepartmentName = "Covent Garden", DepartmentID = Guid.Parse("76000300-0000-0070-9304-000068336078"), DepartmentCode = "C" }); /************************/ /************************/ //Getting a list of producegroups - in this case one is hard coded but could be more; but needs to be passed from the page somehow produceGroupfeeds.Add(new ProduceGroup { ProduceGroupName = "SPROUTS", ProduceGroupID = Guid.Parse("76002000-0000-0070-9304-000068336078"), ProduceGroupCode = "C" }); /************************/ } /*******************************************************/ //AK: This is to get back stockboard results for any department(s) selected /*******************************************************/ foreach (Department d in departmentFeeds) { foreach (vwStockBoard sb in Results) { if (sb.DepartmentID == d.DepartmentID) { DepartmentResultsFeed.Add(sb); } } } //DepartmentResultsFeed is not returned currently - need to implement on view. /*******************************************************/ /*******************************************************/ //AK: This is to get back stockboard results for any producegroup(s) selected /*******************************************************/ foreach (ProduceGroup pg in produceGroupfeeds) { foreach (vwStockBoard sb in Results) { if (sb.ProduceGroupID == pg.ProduceGroupID) { produceGroupResultsFeed.Add(sb); } } } //DepartmentResultsFeed is not returned currently - need to implement on view. /*******************************************************/ //return results just for this stockboardID return(Results); }