public List <CustomerOrderHistory> GetCustomerOrderHistory(string customerId) { var history = new List <CustomerOrderHistory>(); using (var connection = factory.CreateConnection()) { connection.ConnectionString = connectionString; var command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "Northwind.CustOrderHist"; var custIdParam = command.CreateParameter(); custIdParam.ParameterName = "@CustomerID"; custIdParam.DbType = DbType.String; custIdParam.Value = customerId; command.Parameters.Add(custIdParam); connection.Open(); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var order = new CustomerOrderHistory(); order.ProductName = (string)reader["ProductName"]; order.Total = (int)reader["Total"]; history.Add(order); } } } return(history); }
public void MapFromDataTableByMapFunc(int firstResult, int maxResults) { Func <DataRow, CustomerOrderHistory> @mapper = row => { var history = new CustomerOrderHistory { ProductName = row["ProductName"].ToString(), Total = row["Total"].AsIntNullable() }; return(history); }; using ( var table = NorthwindAdoRepository.ExecuteDataTableByProcedure("CustOrderHist", firstResult, maxResults, CustomerTestParameter)) { var histories = table.Map(@mapper).ToList(); if (maxResults > 0) { Assert.GreaterOrEqual(maxResults, histories.Count); } else { Assert.Greater(histories.Count, 0); } } }
public List <CustomerOrderHistory> GetCustomerOrderHistory(Customer custHistory) { List <CustomerOrderHistory> orders = new List <CustomerOrderHistory>(); var query = from customerS in _dbContext.Customers join order in _dbContext.Orders on customerS.CustomerId equals order.CustomerId join orderD in _dbContext.OrderDetails on order.OrderId equals orderD.OrderId join inv in _dbContext.Inventory on orderD.InventoryId equals inv.InventoryId join prod in _dbContext.Products on inv.ProductId equals prod.ProductId where customerS.FirstName == custHistory.FirstName && customerS.LastName == custHistory.LastName select new { order.LocationId, customerS.FirstName, customerS.LastName, order.Date, prod.Pname, prod.Price }; foreach (var item in query) { CustomerOrderHistory coh = new CustomerOrderHistory { LocationID = item.LocationId, Name = $"{item.FirstName} {item.LastName}", Date = item.Date, Pname = item.Pname, Price = item.Price }; orders.Add(coh); } return(orders); }
public ActionResult Purchase(int itemList, double total) { CustomerOrderHistory coh = new CustomerOrderHistory(); coh.LocId = (int)HttpContext.Session.GetInt32("LocId"); coh.CustId = _customerBL.GetCustomerByEmail(HttpContext.Session.GetString("UserEmail")).Id; coh.OrderDate = DateTime.Now; coh.OrderId = itemList; coh.Total = total; _customerOrderHistoryBL.AddCustomerOrderHistory(coh); CustomerCart cart = new CustomerCart(); /*cart.CustId = coh.CustId; * cart.LocId = coh.LocId;*/ cart = _cartBL.GetCustomerCartByIds(coh.CustId, coh.LocId); cart.CurrentItemsId = _orderLineItemBL.Ident_Curr() + 1; _cartBL.UpdateCustomerCart(cart); CustomerOrderLineItem orderLineItem = new CustomerOrderLineItem(); orderLineItem.OrderId = cart.CurrentItemsId; orderLineItem.ProdId = null; orderLineItem.Quantity = 0; orderLineItem.ProdPrice = 0; _orderLineItemBL.AddCustomerOrderLineItem(orderLineItem); return(Redirect($"/InventoryLineItem?locId={HttpContext.Session.GetInt32("LocId")}")); }
public void UpdateCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BUpated) { Entity.CustomerOrderHistory oldCustomerOrderHistory = _context.CustomerOrderHistories.Find(customerOrderHistory2BUpated.Id); _context.Entry(oldCustomerOrderHistory).CurrentValues.SetValues(_mapper.ParseCustomerOrderHistory(customerOrderHistory2BUpated)); _context.SaveChanges(); _context.ChangeTracker.Clear(); }
public void UpdateCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BUpdated, CustomerOrderHistory updatedDetails) { customerOrderHistory2BUpdated.LocId = updatedDetails.LocId; customerOrderHistory2BUpdated.CustId = updatedDetails.CustId; customerOrderHistory2BUpdated.OrderDate = updatedDetails.OrderDate; customerOrderHistory2BUpdated.OrderId = updatedDetails.OrderId; customerOrderHistory2BUpdated.Total = updatedDetails.Total; _repo.UpdateCustomerOrderHistory(customerOrderHistory2BUpdated); }
public CustomerOrderHistory UpdateCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BUpated) { CustomerOrderHistory oldCustomerOrderHistory = _context.CustomerOrderHistories.Find(customerOrderHistory2BUpated.Id); _context.Entry(oldCustomerOrderHistory).CurrentValues.SetValues(customerOrderHistory2BUpated); _context.SaveChanges(); _context.ChangeTracker.Clear(); return(customerOrderHistory2BUpated); }
public OrderHistoryCRVM cast2OrderHistoryCRVM(CustomerOrderHistory orderHistory) { return(new OrderHistoryCRVM { LocId = orderHistory.LocId, CustId = orderHistory.CustId, OrderDate = orderHistory.OrderDate, OrderId = orderHistory.OrderId, Total = orderHistory.Total }); }
public OrderHistoryIndexVM cast2OrderHistoryIndexVM (CustomerOrderHistory orderHistory2BCasted, Location loc, List <CartIndexVM> cart2BCasted) { return(new OrderHistoryIndexVM { OrderId = orderHistory2BCasted.OrderId, OrderDate = orderHistory2BCasted.OrderDate, LocName = loc.LocName, CustId = orderHistory2BCasted.CustId, Total = orderHistory2BCasted.Total, Id = orderHistory2BCasted.Id }); }
public CustomerOrderHistory GetOrderDetails() { CustomerOrderHistory newOrder = new CustomerOrderHistory(); newOrder.LocId = _location.Id; newOrder.CustId = _user.Id; newOrder.OrderDate = DateTime.Now; newOrder.OrderId = _customerCart.CurrentItemsId; newOrder.Total = 0; foreach (var item in _customerOrderLineItemBL.GetCustomerOrderLineItems()) { if (item.OrderId == newOrder.OrderId) { newOrder.Total += (_productBL.GetProductById((int)item.ProdId).ProdPrice *item.Quantity); UpdateInventory(item); } } return(newOrder); }
public CustomerOrderHistory DeleteCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BDeleted) { _context.CustomerOrderHistories.Remove(customerOrderHistory2BDeleted); _context.SaveChanges(); return(customerOrderHistory2BDeleted); }
public CustomerOrderHistory AddCustomerOrderHistory(CustomerOrderHistory newCustomerOrderHistory) { _context.CustomerOrderHistories.Add(newCustomerOrderHistory); _context.SaveChanges(); return(newCustomerOrderHistory); }
public CustomerOrderHistory AddCustomerOrderHistory(CustomerOrderHistory newCustomerOrderHistory) { //TODO: Add BL return(_repo.AddCustomerOrderHistory(newCustomerOrderHistory)); }
public void SaveCustomerOrderHistory(EventCustomer eventCustomer, long corporateUploadId, long oldEventPackageId, long newEventPackageId, IEnumerable <long> oldEventTestIds, IEnumerable <long> newEventTestIds) { var customerOrderHistories = new List <CustomerOrderHistory>(); if (oldEventPackageId > 0) { var model = new CustomerOrderHistory { UploadId = corporateUploadId, EventCustomerId = eventCustomer.Id, EventId = eventCustomer.EventId, CustomerId = eventCustomer.CustomerId, EventPackageId = oldEventPackageId, OrderItemStatusId = (long)OrderItemStatus.Old, }; customerOrderHistories.Add(model); } if (newEventPackageId > 0) { var model = new CustomerOrderHistory { UploadId = corporateUploadId, EventCustomerId = eventCustomer.Id, EventId = eventCustomer.EventId, CustomerId = eventCustomer.CustomerId, EventPackageId = newEventPackageId, OrderItemStatusId = (long)OrderItemStatus.New, }; customerOrderHistories.Add(model); } if (oldEventPackageId > 0 && newEventPackageId <= 0) { var model = new CustomerOrderHistory { UploadId = corporateUploadId, EventCustomerId = eventCustomer.Id, EventId = eventCustomer.EventId, CustomerId = eventCustomer.CustomerId, EventPackageId = oldEventPackageId, OrderItemStatusId = (long)OrderItemStatus.Existing, }; customerOrderHistories.Add(model); } if (oldEventTestIds != null && oldEventTestIds.Any()) { foreach (var eventTestId in oldEventTestIds) { var model = new CustomerOrderHistory { UploadId = corporateUploadId, EventCustomerId = eventCustomer.Id, EventId = eventCustomer.EventId, CustomerId = eventCustomer.CustomerId, EventTestId = eventTestId, OrderItemStatusId = (long)OrderItemStatus.Old, }; customerOrderHistories.Add(model); } } if (newEventTestIds != null && newEventTestIds.Any()) { foreach (var eventTestId in newEventTestIds) { var model = new CustomerOrderHistory { UploadId = corporateUploadId, EventCustomerId = eventCustomer.Id, EventId = eventCustomer.EventId, CustomerId = eventCustomer.CustomerId, EventTestId = eventTestId, OrderItemStatusId = oldEventTestIds != null && oldEventTestIds.Any() && oldEventTestIds.Contains(eventTestId) ? (long)OrderItemStatus.Existing : (long)OrderItemStatus.New, }; customerOrderHistories.Add(model); } } _customerOrderHistoryRepository.Save(customerOrderHistories); }
public void DeleteCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BDeleted) { _repo.DeleteCustomerOrderHistory(customerOrderHistory2BDeleted); }
public void AddCustomerOrderHistory(CustomerOrderHistory newCustomerOrderHistory) { //TODO: Add BL _repo.AddCustomerOrderHistory(newCustomerOrderHistory); }
public CustomerOrderHistory UpdateCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BUpdated) { return(_repo.UpdateCustomerOrderHistory(customerOrderHistory2BUpdated)); }
public CustomerOrderHistory DeleteCustomerOrderHistory(CustomerOrderHistory customerOrderHistory2BDeleted) { return(_repo.DeleteCustomerOrderHistory(customerOrderHistory2BDeleted)); }