protected void btnAddToCart_Click(object sender, EventArgs e) { desc.InnerText = ""; var book = BookCatalogDataAccess.GetBookById(ddlBookSelection.SelectedValue); // Add the book to an order BookOrder order = new BookOrder(book, Convert.ToInt32(txtQuantity.Text)); // Add the order to the cart ShoppingCart cart = ShoppingCart.RetrieveShoppingCart(); cart.AddBookOrder(order); var itemText = " item"; var copyText = " copy"; if (cart.NumOfItems > 1) { itemText = " items"; copyText = " copies"; } // Display confirmation desc.InnerText = txtQuantity.Text + copyText + " of " + book.Title + " is added to the shopping cart"; // Update the cart item count btnViewCart.Text = "View Cart (" + cart.NumOfItems + itemText + ")"; // Update the dropdown ddlBookSelection.Items.RemoveAt(ddlBookSelection.SelectedIndex); ddlBookSelection.SelectedValue = "-1"; }
public void SendingABookOrder_WhenStateIsNotApproved_ShouldThrowDomainException(BookOrderState state) { var sut = CreateSut(); BookOrder bookOrder = a.BookOrder; _bookOrderRepository.Store(bookOrder); Action sendBookOrderThatIsAlreadySent = () => sut.Execute(bookOrder.Id); sendBookOrderThatIsAlreadySent.ShouldThrow <Exception>(); }
public void ApprovedBookOrder_ShouldBeSentToSupplierGateway() { var sut = CreateSut(); BookOrder bookOrder = a.BookOrder.ThatIsApproved(); _bookOrderRepository.Store(bookOrder); sut.Execute(bookOrder.Id); _bookSupplierGatewayInMemory.SentBookOrders.Should().Contain(bookOrder); }
public static BookOrder ToDomain(this BookOrderDto dto) { BookOrderState state = dto.State.ToDomain(); List <OrderLine> orderLines = new List <OrderLine>(); foreach (var dtoOrderLine in dto.OrderLines) { orderLines.Add(new OrderLine(dtoOrderLine.Title, dtoOrderLine.Price, dtoOrderLine.Quantity, dtoOrderLine.Id)); } return(BookOrder.CreateExisting(dto.Supplier, dto.Id, state, orderLines)); }
public async Task <IActionResult> Create([Bind("BookOrderID,Price,OrderQuantity")] BookOrder bookOrder) { if (ModelState.IsValid) { _context.Add(bookOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bookOrder)); }
//After initialization loading books private void Window_Loaded(object sender, RoutedEventArgs e) { BookCatalog bookCat = new BookCatalog(); dsBookCat = bookCat.GetBookInfo(); this.DataContext = dsBookCat.Tables["Category"]; bookOrder = new BookOrder(); userData = new UserData(); this.orderListView.ItemsSource = bookOrder.OrderItemList; searchComboBox.SelectedIndex = 0; }
public IActionResult Create([FromBody] BookOrder order) { if (order == null) { return(BadRequest()); } _context.orders.Add(order); _context.SaveChanges(); return(CreatedAtRoute("GetTodo", new { id = order.id }, order)); }
public void Order_BookProduct_GenerateDuplicatePackingSlip() { // Arrange var order = new BookOrder("Book"); // Act var result = order.GenerateOrder(); // Assert Assert.AreEqual("GenerateOrder: Packing slip for royalty department is generated for item Book.", result); }
protected void btnAddToCart_Click(object sender, EventArgs e) { if (drpBookSelection.SelectedIndex != 0) { var cart = Session["cart"] as ShoppingCart ?? new ShoppingCart(); var book = BookCatalogDataAccess.GetBookById(drpBookSelection.SelectedValue); BookOrder order = new BookOrder(book, int.Parse(txtQuantity.Text)); cart.AddBookOrder(order); drpBookSelection.Items.Remove(new ListItem(book.Title,book.Id)); txtQuantity.Text = string.Empty; } }
protected void btnAddToCart_Click(object sender, EventArgs e) { if (drpBookSelection.SelectedValue != "-1" && Session["shoppingcart"] != null) { //todo: Retrieve selected book from the session - OK Book selectedBook = (Book)Session["selectedBooksSession"]; String bookTitle = selectedBook.Title; //creating book title string //todo: get user entered quqntity - OK int bookQuantity = int.Parse(txtQuantity.Text); //todo: Create a book order with selected book and quantity - OK BookOrder newOrder = new BookOrder(selectedBook, bookQuantity); //todo: Retrieve to cart from the session - OK ShoppingCart newCart = new ShoppingCart(); if (Session["shoppingcart"] != null) { newCart = (ShoppingCart)Session["shoppingcart"]; } //todo: Add book order to the shopping cart - OK newCart.AddBookOrder(newOrder); Session["shoppingcart"] = newCart; //todo: Remove the selected item from the dropdown list - OK drpBookSelection.Items.Remove(drpBookSelection.SelectedItem); //todo: Set the description to show title and quantity of the book user added to the shopping cart - OK lblDescription.Text = ""; lblPrice.Text = ""; lblDescription.Text = txtQuantity.Text + " copy(s) of " + bookTitle + " was added to the shopping cart."; txtQuantity.Text = ""; //todo: Set the dropdown list's selected value as "-1" - OK drpBookSelection.SelectedIndex = -1; //todo: Update the number of items in shopping cart displayed next to the link to ShoppingCartView.aspx - OK if (newCart.NumOfItems == 0) { lblNumItems.Text = "empty"; } else if (newCart.NumOfItems == 1) { lblNumItems.Text = "1 item"; } else { lblNumItems.Text = newCart.NumOfItems.ToString() + " items"; } } }
static void Main(string[] args) { var factory = new ConnectionFactory() { HostName = "localhost", UserName = "******", Password = "******" }; using (var connection = factory.CreateConnection()) { using (var channel = connection.CreateModel()) { channel.ExchangeDeclare(Exchange, "topic"); channel.QueueDeclare(PaymentQueueName, true, false, false); channel.QueueDeclare(BookOrderQueueName, true, false, false); channel.QueueDeclare(AllMessageQueue, true, false, false); // Receieve only payments channel.QueueBind(PaymentQueueName, Exchange, "sample.payment"); // Receieve only book orders channel.QueueBind(BookOrderQueueName, Exchange, "sample.bookorder"); // Receive all messages channel.QueueBind(AllMessageQueue, Exchange, "sample.*"); int defaultMessageCount = 10; Console.WriteLine("Please enter message count for publish (topic):"); var enteredMessageCount = Console.ReadLine(); Int32.TryParse(enteredMessageCount, out defaultMessageCount); for (int i = 0; i < defaultMessageCount; i++) { var payment = new Payment { Amount = 2000, CreditCardNumber = "444666888" }; channel.BasicPublish(Exchange, "sample.payment", null, payment.SerializeObject()); Console.WriteLine($"Payment Sent (Topic : sample.payment) Amount : {payment.Amount} Credit Card Number : {payment.CreditCardNumber}"); Console.WriteLine("----------------------------------------------------------------------------------------------------------------"); var bookOrder = new BookOrder { Amount = 3000, OrderDate = DateTime.Now, OrderNumber = Guid.NewGuid().ToString() }; channel.BasicPublish(Exchange, "sample.bookorder", null, bookOrder.SerializeObject()); Console.WriteLine($"Book Order Sent (Topic : sample.bookorder) Amount : {bookOrder.Amount} Date : {bookOrder.OrderDate} Order Number : {bookOrder.OrderNumber}"); } } } Console.ReadLine(); }
public ReturnBookResult ReturnBook(BookOrder bookOrder) { Contracts.Require(bookOrder != null, "BookOrder argument cannot be null"); bookOrder.OrderStatus = OrderStatus.Returned; _libraryContext.BookOrders.Update(bookOrder); _libraryContext.SaveChanges(); return(new ReturnBookResult { Success = true, Message = "Successfully returned book to the library!" }); }
public ActionResult <RequestBookResult> ReturnBook(int bookId, [FromBody] int returningUserId) { BookOrder bookOrder = _bookOrderRepository.GetLatestBookOrder(bookId, returningUserId); if (bookOrder == null || bookOrder.OrderStatus != OrderStatus.Borrowed) { return(NotFound("Failed to return the book. This user didn't have this book borrowed.")); } ReturnBookResult result = _bookOrderRepository.ReturnBook(bookOrder); return(Ok(result)); }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { try { DateTime d2 = DateTime.Now; Label5.Text = Session["m1"].ToString(); // Label13 .Text ="Dear : " + Session["cname"] + "Your Order Sueesfully Send to Admin Wais a few Secound ther are Reply For ur order"; BookOrder.Addorder(1, int.Parse(Session["ordernumber"].ToString()), int.Parse(Session["uid"].ToString()), d2); Session["oids"] = BookOrder.orderid.ToString(); Label12.Text = "Dear : " + Session["cname"] + "Your order Number is" + Session ["oids"] + "Plase Note This Order ID"; } catch {} }
public bool Edit(BookOrder bookOrder) { try { _BookOrderRepository.UpdateBookOrder(bookOrder); _BookOrderRepository.Save(); } catch (DataException ex) { return(false); } return(true); }
public void NewBookOrder_ShouldBeApproved() { var sut = CreateSut(); BookOrder bookOrder = a.BookOrder.ThatIsNew(); _bookOrderRepository.Store(bookOrder); sut.Execute(bookOrder.Id); var storedBookOrder = _bookOrderRepository.Get(bookOrder.Id); storedBookOrder.State.Should().Be(BookOrderState.Approved); }
public void CanStoreAndRetrieve_ANewBookOrder() { var sut = CreateSut(); var orderId = Guid.NewGuid(); sut.Store(BookOrder.CreateNew("SomeSupplier", orderId)); var bookOrder = sut.Get(orderId); bookOrder.Supplier.Should().Be("SomeSupplier"); bookOrder.Id.Should().Be(orderId); bookOrder.State.Should().Be(BookOrderState.New); }
protected void LinkButton1_Click(object sender, EventArgs e) { try { int val = int.Parse(BookOrder.getvalcount("Select Count (*) from Member where Username='******'")); int val1 = int.Parse(BookOrder.getvalcount("Select Count (*) from Member where Email='" + TextBox8.Text.ToString() + "'")); if (val1 == 0) { if (val == 0) { if (CheckBox1.Checked == true) { if (TextBox13.Text == TextBox14.Text) { BookOrder.Addmember(1, TextBox1.Text.ToString(), TextBox2.Text.ToString(), TextBox3.Text.ToString(), DropDownList1.Text.ToString(), DropDownList2.Text.ToString(), TextBox4.Text.ToString(), TextBox8.Text.ToString(), TextBox6.Text.ToString(), TextBox7.Text.ToString(), TextBox5.Text.ToString(), TextBox9.Text.ToString(), DateTime.Parse(TextBox10.Text.ToString()), DateTime.Parse(TextBox11.Text.ToString()), TextBox12.Text.ToString(), TextBox13.Text.ToString()); Label30.Text = ""; Label31.Text = ""; Label29.Text = ""; Label28.Text = ""; Session["m2"] = ""; Session["m1"] = "Dear : " + TextBox1.Text.ToString() + " Wait A Few Secound We Will Send A Reply For Your Conformation "; Session["m2"] = "Dear : " + TextBox1.Text.ToString() + "Welcome our site .your Are New member . "; Session["cname"] = TextBox1.Text.ToString(); Session["uid"] = BookOrder.memberno.ToString(); Response.Redirect("~/Member site/Membership.aspx"); } else { Label30.Text = "Check Password ReEnter"; } } else { Label31.Text = "Checked the Agree Option"; } } else { Label29.Text = "Available"; } } else { Label28.Text = "Available"; } } catch { } }
public async Task UpdateBookedTime(BookOrder bookOrder) { if (bookOrder.EndingDate < DateTime.Now) { var animal = _animalRepository.Entities.FirstOrDefault(x => x.Id == bookOrder.AnimalId); animal.Status = Domain.Enums.AnimalStatus.None; bookOrder.Status = Domain.Enums.OrderStatus.Declined; _animalRepository.Update(animal); _bookOrderRepository.Update(bookOrder); await _animalRepository.SaveAsync(); await _bookOrderRepository.SaveAsync(); } }
protected void btnAddToCart_Click(object sender, EventArgs e) { if (drpBookSelection.SelectedValue != "-1" && Session["shoppingcart"] != null) { //////todo: Retrieve selected book from the session var book = BookCatalogDataAccess.GetBookById(drpBookSelection.SelectedValue); ////todo: get user entered quqntity int quantity = Int16.Parse(txtQuantity.Text); ////todo: Create a book order with selected book and quantity BookOrder order = new BookOrder(book, quantity); ////todo: Retrieve to cart from the session var cart = (ShoppingCart)Session["shoppingcart"]; ////todo: Add book order to the shopping cart cart.AddBookOrder(order); ////todo: Remove the selected item from the dropdown list drpBookSelection.Items.RemoveAt(drpBookSelection.SelectedIndex); ////todo: Set the dropdown list's selected value as "-1" drpBookSelection.ClearSelection(); txtQuantity.Text = string.Empty; ////todo: Set the description to show title and quantity of the book user added to the shopping cart lblDescription.Text = "You have added " + quantity + " copies of: " + book.Title; ////todo: Update the number of items in shopping cart displayed next to the link to ShoppingCartView.aspx if (cart.NumOfItems == 0) { lblNumItems.Text = "empty"; } else if (cart.NumOfItems == 1) { lblNumItems.Text = "1 item"; } else { lblNumItems.Text = cart.NumOfItems.ToString() + " items"; } } }
protected void btnAddToCart_Click(object sender, EventArgs e) { Page.Validate(); if (quantityValidator.IsValid) { quantityValidator.CssClass = "hide"; } if (Page.IsValid && drpBookSelection.SelectedValue != "-1" && Session["shoppingcart"] != null) { //todo: Retrieve selected book from the session Book selectedBook = (Book)Session["currentBook"]; //todo: get user entered quqntity string str = txtQuantity.Text.ToString().Trim(); int qnt = 0; try { qnt = Convert.ToInt32(str); } catch (Exception exc) { return; } if (qnt > 0) { //todo: Create a book order with selected book and quantity BookOrder order = new BookOrder(selectedBook, qnt); //todo: Retrieve to cart from the session ShoppingCart shoppingCart = (ShoppingCart)Session["shoppingcart"]; //todo: Add book order to the shopping cart shoppingCart.AddBookOrder(order); Session["shoppingcart"] = shoppingCart; //todo: Remove the selected item from the dropdown list Response.Redirect("BookStore.aspx"); } //todo: Set the dropdown list's selected value as "-1" //todo: Set the description to show title and quantity of the book user added to the shopping cart //todo: Update the number of items in shopping cart displayed next to the link to ShoppingCartView.aspx } }
public void GetBySupplierAndState_WhenNoMatchesForState_ShouldReturnEmptyList() { var sut = CreateSut(); var bookOrder1 = BookOrder.CreateExisting("Foo", Guid.NewGuid(), BookOrderState.Sent, new List <OrderLine>() { new OrderLine("Line1Book", 100M, 2, Guid.NewGuid()) }); sut.Store(bookOrder1); var results = sut.GetBySupplier("Foo", BookOrderState.New).ToList(); results.Should().BeEmpty(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { BookCatalog bookCat = new BookCatalog(); dsBookCat = bookCat.GetBookInfo(); //this.DataContext = dsBookCat.Tables["Category"]; bookOrder = new BookOrder(); userData = new UserData(); if (!userData.LoggedIn) { this.statusTextBlock.Text = "You are currently browsing as a Guest. Please log in."; } // this.orderListView.ItemsSource = bookOrder.OrderItemList; }
private BookOrder StoreBookOrderWithOrderLineForSupplier(string supplier) { BookOrder bookOrder = BookOrder.CreateNew( "SupplierBar", Guid.NewGuid()); bookOrder.AddBookRequest( a.BookTitleOrder .ForSupplier(supplier) .ForTitle("The Hobbit") ); _bookOrderRepository.Store(bookOrder); return(bookOrder); }
public string GenerateBookBorrowOrderID(BookOrder order) { string res = "BBAHVN_"; res += order.DateCreated.Value.Date.ToString("ddMMyy") + "_"; Table <DAL.OrderBasicInfo> orderTable = GetOrderBasicInfoTable(); var matchedRes = (from o in orderTable where o.orderID.Contains(res) == true select o).ToList(); res += (matchedRes.Count + 1).ToString(); return(res); }
public BookOrder Get(Guid orderId) { using (var connection = CreateConnection()) { var bookOrderDto = new GetBookOrderAction(connection).Execute(orderId); var bookOrderLineDtos = new GetBookOrderLinesAction(connection).Execute(bookOrderDto.Order_Id); List <OrderLine> lines = OrderLineFactory.CreateFrom(bookOrderLineDtos); var bookOrder = BookOrder.CreateExisting( bookOrderDto.Supplier, bookOrderDto.State, bookOrderDto.Order_Id, lines); return(bookOrder); } }
public void TestPriceTotal() { BookOrder newOrder; try { newOrder = new BookOrder(); double newTotal = newOrder.GetOrderTotal(); Assert.AreEqual(0, newTotal); } catch { Assert.Fail("Exception should be thrown"); } }
private BookOrder ReadItem(SqlDataReader reader) { int boId = reader.IsDBNull(0) ? 0 : reader.GetInt32(0); int orderId = reader.IsDBNull(1) ? 0 : reader.GetInt32(1); int bookId = reader.IsDBNull(2) ? 0 : reader.GetInt32(2); BookOrder item = new BookOrder() { BOId = boId, OrderId = orderId, Bookid = bookId, }; return(item); }
protected void LinkButton2_Click(object sender, EventArgs e) { try { SqlDataReader dr1 = BookOrder.Getview("SELECT Memberid from Member where UserName='******'"); while (dr1.Read()) { //Label3.Text = dr1.GetValue(0).ToString(); Session["mid1"] = dr1.GetValue(0).ToString(); TextBox1.Text = dr1.GetValue(0).ToString(); } Response.Redirect("~/Admin/lendpage.aspx"); } catch { } }
public void ShouldBeAbleToStoreAndGetBookOrder() { var sut = CreateSut(); Guid orderId = Guid.NewGuid(); var newBookOrder = BookOrder.CreateNew("Foo", orderId); newBookOrder.AddBookRequest(new BookTitleRequest("Book1", "Foo", 10.5M, 2)); sut.Store(newBookOrder); var storedOrder = sut.Get(orderId); storedOrder.ShouldBeEquivalentTo(newBookOrder); }
/// <summary> /// Applies the order to the specified IQueryable object. /// </summary> /// <param name="books">The books.</param> /// <param name="order">The order.</param> /// <returns>The books ordered by <paramref name="order"/>.</returns> private IQueryable <Book> ApplyOrder(IQueryable <Book> books, BookOrder order) { books = order switch { BookOrder.ByTitleDescending => books.OrderByDescending(b => b.Title), BookOrder.ByAuthorAscending => books.OrderBy(b => b.Author), BookOrder.ByAuthorDescending => books.OrderByDescending(b => b.Author), BookOrder.ByCreationDateAscending => books.OrderBy(b => b.CreationDate), BookOrder.ByCreationDateDescending => books.OrderByDescending(b => b.CreationDate), BookOrder.ByNumberOFDownloadsAscending => books.OrderBy(b => b.TotalDownloads), BookOrder.ByNumberOfDownloadsDescending => books.OrderByDescending(b => b.TotalDownloads), _ => books.OrderBy(b => b.Title), }; return(books); }
//POST : BookOrder/Create public IActionResult CreateAuto() { AppUser user = _context.Users.FirstOrDefault(u => u.UserName == User.Identity.Name); DefaultReorder reorder = _context.ReorderQuantity.FirstOrDefault(u => u.DefaultReorderID == 1); List <Book> ReorderBooks = GetReorderBooks(); //list of orders List <BookOrder> bookorders = new List <BookOrder>(); //list of book orders in database List <BookOrder> boalreadyindb = _context.BookOrders.ToList(); //list of books we already have book orders for List <Book> titlesbookorder = new List <Book>(); foreach (BookOrder bookorder in boalreadyindb) { titlesbookorder.Add(bookorder.Book); } //list of order details foreach (Book b in ReorderBooks) { bool alreadyExist = titlesbookorder.Contains(b); //if book doesnt have order if (alreadyExist == false) { //create orders BookOrder bo = new BookOrder(); bo.AppUser = user; bo.ReorderQuantity = reorder; bo.Book = b; bo.Quantity = bo.ReorderQuantity.DefaultQuantity; bo.Price = b.SupplierPrice; bo.InReorderList = true; bookorders.Add(bo); _context.BookOrders.Add(bo); } } _context.SaveChanges(); return(RedirectToAction("AutoReorder")); }
protected void btnAddToCart_Click(object sender, EventArgs e) { Validate(); if (Page.IsValid) { Book book = BookCatalogDataAccess.GetBookById(BookList.SelectedValue); int quantity = Int16.Parse(txtQauntity.Text); BookOrder order = new BookOrder(book, quantity); cart.AddBookOrder(order); BookList.Items.RemoveAt(BookList.SelectedIndex); string amount = quantity > 1 ? "copies" : "copy"; lblDescription.Text = quantity + " " + amount + " of " + book.Title + " have been added to your cart"; btnViewCart.Text = "View Cart (" + cart.NumOfItems + " items)"; BookList.ClearSelection(); txtQauntity.Text = ""; } }
public IQueryable<Book> Get(string profileIds = null, string search = null, BookOrder orderBy = BookOrder.Default, int skip = 0, int take = 128) { var query = Docs .Query<Books_WithProfiles.Result, Books_WithProfiles>(); if (!string.IsNullOrWhiteSpace(profileIds)) query = query.Search(r => r.ProfileIds, string.Join(" ", profileIds.Split(',')), options: SearchOptions.And); if (!string.IsNullOrWhiteSpace(search)) query = query.Search(r => r.Query, search, options:SearchOptions.And); query = (IRavenQueryable<Books_WithProfiles.Result>) query .Skip(skip) .Take(take); switch (orderBy) { case BookOrder.Default: query = (IRavenQueryable<Books_WithProfiles.Result>) query.OrderByDescending(b => b.Rating) .ThenByDescending(b => b.PublishDate); break; case BookOrder.Title: query = query.OrderBy(b => b.Title); break; case BookOrder.PublishDate: query = query.OrderByDescending(b => b.PublishDate); break; case BookOrder.Rating: query = query.OrderByDescending(b => b.Rating); break; } return query.AsProjection<Book>(); }
public static ArrayList RetrieveAllBookOrders() { ArrayList orders = new ArrayList(); StreamReader sr = null; try { string path = HttpContext.Current.Request.PhysicalApplicationPath; string filePath = path + @"\App_Data\BookOrderList.txt"; if (!File.Exists(filePath)) { return orders; } FileStream bookOrderList = new FileStream(filePath, FileMode.Open, FileAccess.Read); sr = new StreamReader(bookOrderList); while (!sr.EndOfStream) { string bookId = sr.ReadLine(); int quantity = int.Parse(sr.ReadLine()); Book book = BookCatalogDataAccess.GetBookById(bookId); BookOrder bookOrder = new BookOrder(book, quantity); orders.Add(bookOrder); } } catch (Exception) { ClearBookOrderList(); } finally { if (sr != null) { sr.Close(); } } return orders; }
public void AddBookOrder(BookOrder order) { bookOrders.Add(order); BookOrderListDataAccess.SaveBookOrder(order); }
public static void SaveBookOrder(BookOrder bookOrder) { ArrayList orders = RetrieveAllBookOrders(); orders.Add(bookOrder); SaveBookOrders(orders); }
public void AddBookOrder(BookOrder order) { bookOrders.Add(order); }