public OrderViewModel(Order order) { Product = order.Product; Price = order.Price; DeliveryDate = order.DeliveryDate; IsReady = order.IsReady; User = order.User; ProductCode = order.ProductCode; }
public void Delete(Order order) { var orderToDelete = Get(order.Id); if (orderToDelete != null) { _context.Orders.Remove(orderToDelete); _context.SaveChanges(); } }
public void Update(Order order) { var orderToUpdate = Get(order.Id); if (orderToUpdate != null) { orderToUpdate = order; _context.SaveChanges(); } }
public bool UpdateOrder(Order order) { var exisitingOrder = GetOrderById(order.Id); if(exisitingOrder != null) { exisitingOrder = order; _context.SaveChanges(); return true; } return false; }
public bool DeleteOrder(Order order) { var exisitingOrder = GetOrderById(order.Id); if(exisitingOrder != null) { _context.Orders.Remove(exisitingOrder); _context.SaveChanges(); return true; } return false; }
public void AssertThatAddOrderReturnsAddedOrder() { var order = new Order() { Id = 103, Price = 343, IsReady = false, DeliveryDate = DateTime.Now.AddDays(10), Product = new Product() { Id = 1 } }; Assert.AreSame(order, _service.AddOrder(order)); }
public bool UpdateOrder(Order order) { return _repository.UpdateOrder(order); }
public bool DeleteOrder(Order order) { return _repository.DeleteOrder(order); }
public Order AddOrder(Order order) { return _repository.AddOrder(order); }
public void UpdateOrder(Order order) { _repository.Update(order); }
public void DeleteOrder(Order order) { _repository.Delete(order); }
public Order Add(Order order) { _context.Orders.Add(order); _context.SaveChanges(); return order; }
public ActionResult SelectParts(CustomizeProductViewModel viewModel) { var selectedPartList = viewModel.Product.Parts.Where(p => p.IsSelected == true).ToList(); if(selectedPartList!=null) { var deliveryDate = DateTime.Now.AddDays(selectedPartList.OrderByDescending(d => d.LeadTime).First().LeadTime); int productId = viewModel.Product.Id; StringBuilder productCode = new StringBuilder(); decimal productPrice = 0; bool isReady = false; var userID = _userService.Get(HttpContext.User.Identity.Name).Entity; foreach(var part in selectedPartList) { productPrice += part.Price; isReady = deliveryDate > DateTime.Now ? false : true; productCode.Append(part.StockKeepingUnit.Substring(0,2)); } var order = new Order { Product = _productService.GetProduct(viewModel.Product.Id), DeliveryDate = deliveryDate, IsReady = isReady, Price = productPrice, ProductId = productId, User = userID }; _orderService.AddOrder(order); } return View("~/Views/User/SelectParts.cshtml"); }
public ActionResult SelectParts(CustomizeProductViewModel viewModel) { var selectedPartList = viewModel.Product.Parts.Where(p => p.IsSelected == true).ToList(); var totalCat = viewModel.Product.Parts.Select(p => p.CategoryId).Distinct().ToArray(); // Setup so that one part of every category must be selected before completion if (selectedPartList.Count() != totalCat.Count()) { return View(viewModel); } var partList = new List<Part>(); foreach (var item in selectedPartList) { partList.Add(_productService.GetProduct(viewModel.Product.Id).Parts.SingleOrDefault(p => p.Id == item.Id)); } if (partList != null || partList.Count > 0) { double orderLeadtime = new double(); foreach (var item in partList) { orderLeadtime += item.LeadTime; } StringBuilder productCode = new StringBuilder(); var order = new Order() { Product = _productService.GetProduct(viewModel.Product.Id), DeliveryDate = DateTime.Now.AddDays(orderLeadtime), IsReady = false, User = _userService.Get(HttpContext.User.Identity.Name).Entity }; foreach (var part in partList) { order.Price += part.Price; order.IsReady = order.DeliveryDate > DateTime.Now ? false : true; productCode.Append(part.StockKeepingUnit); } order.ProductCode = productCode.ToString(); _orderService.AddOrder(order); } return RedirectToAction("OrderList"); }