Ejemplo n.º 1
0
		/// <summary>
		/// Детали заказа для таблицы заказов
		/// </summary>
		/// <param name="OrderID"></param>
		public IEnumerable<OrderDetailsDTO> ShowOrderDetails(int OrderID)
		{
			try {
				List<OrderDetailsDTO> Orders = new List<OrderDetailsDTO>();
				var OrdersDAL = Data.ShowOrderDetails(OrderID);

				foreach (var o in OrdersDAL)
				{
					OrderDetailsDTO order = new OrderDetailsDTO();
					order.OrderID = o.OrderID;
					order.CustomerID = o.CustomerID;
					order.EmployeeID = o.EmployeeID;
					order.OrderDate = o.OrderDate;
					order.RequiredDate = o.RequiredDate;
					order.ShippedDate = o.ShippedDate;
					order.ShipVia = o.ShipVia;
					order.Freight = o.Freight;
					order.ShipName = o.ShipName;
					order.ShipAddress = o.ShipAddress;
					order.ShipCity = o.ShipCity;
					order.ShipRegion = o.ShipRegion;
					order.ShipPostalCode = o.ShipPostalCode;
					order.ShipCountry = o.ShipCountry;
					order.OrderStatus = o.OrderStatus.ToString();
					order.ProductID = o.ProductID;
					order.ProductName = o.ProductName;
					order.Quantity = o.Quantity;
					order.UnitPrice = o.UnitPrice;
					order.Discount = o.Discount;
					Orders.Add(order);
				}
				return Orders;
			}
			catch (ArgumentException ex)
			{
				throw new ValidationException(ex.Message, ex.ParamName);
			}
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Детали заказа для обновления данных
		/// </summary>
		/// <param name="OrderID"></param>
		public OrderDetailsDTO OrderDetails(int OrderID)
		{
			try
			{
				var o = Data.OrderDetails(OrderID);
				OrderDetailsDTO order = new OrderDetailsDTO();
				order.OrderID = o.OrderID;
				order.CustomerID = o.CustomerID;
				order.EmployeeID = o.EmployeeID;
				order.OrderDate = o.OrderDate;
				order.RequiredDate = o.RequiredDate;
				order.ShippedDate = o.ShippedDate;
				order.ShipVia = o.ShipVia;
				order.Freight = o.Freight;
				order.ShipName = o.ShipName;
				order.ShipAddress = o.ShipAddress;
				order.ShipCity = o.ShipCity;
				order.ShipRegion = o.ShipRegion;
				order.ShipPostalCode = o.ShipPostalCode;
				order.ShipCountry = o.ShipCountry;
				order.OrderStatus = o.OrderStatus.ToString();
				order.ProductID = o.ProductID;
				order.ProductName = o.ProductName;
				order.Quantity = o.Quantity;
				order.UnitPrice = o.UnitPrice;
				order.Discount = o.Discount;
				return order;
			}
			catch (ArgumentException ex)
			{
				throw new ValidationException(ex.Message, ex.ParamName);
			}
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Добавление деталей заказа 
		/// </summary>
		/// <param name="order"></param>
		public bool AddOrderDetails(OrderDetailsDTO order)
		{
			try {
				OrderDetails orderDAL = new OrderDetails();
				orderDAL.OrderID = order.OrderID;
				orderDAL.CustomerID = order.CustomerID;
				orderDAL.EmployeeID = order.EmployeeID;
				orderDAL.OrderDate = order.OrderDate;
				orderDAL.RequiredDate = order.RequiredDate;
				orderDAL.ShippedDate = order.ShippedDate;
				orderDAL.ShipVia = order.ShipVia;
				orderDAL.Freight = order.Freight;
				orderDAL.ShipName = order.ShipName;
				orderDAL.ShipAddress = order.ShipAddress;
				orderDAL.ShipCity = order.ShipCity;
				orderDAL.ShipRegion = order.ShipRegion;
				orderDAL.ShipPostalCode = order.ShipPostalCode;
				orderDAL.ShipCountry = order.ShipCountry;
				orderDAL.ProductID = order.ProductID;
				orderDAL.ProductName = order.ProductName;
				orderDAL.Quantity = order.Quantity;
				orderDAL.UnitPrice = order.UnitPrice;
				orderDAL.Discount = order.Discount;

				if (Data.AddOrderDetail(orderDAL) != true)
					return true;
				else return false;
			}
			catch (ArgumentException ex)
			{
				throw new ValidationException(ex.Message, ex.ParamName);
			}
		}
Ejemplo n.º 4
0
		public ActionResult UpdateOrder(OrderDetailsViewModel order)
		{
			try
			{
				if (ModelState.IsValid)
				{
					OrderDetailsDTO OrderBLL = new OrderDetailsDTO();

					OrderBLL.OrderID = order.OrderID;
					OrderBLL.CustomerID = order.CustomerID;
					OrderBLL.EmployeeID = order.EmployeeID;
					OrderBLL.OrderDate = order.OrderDate;
					OrderBLL.RequiredDate = order.RequiredDate;
					OrderBLL.ShippedDate = order.ShippedDate;
					OrderBLL.ShipVia = order.ShipVia;
					OrderBLL.Freight = Convert.ToDouble(order.Freight);
					OrderBLL.ShipName = order.ShipName;
					OrderBLL.ShipAddress = order.ShipAddress;
					OrderBLL.ShipCity = order.ShipCity;
					OrderBLL.ShipRegion = order.ShipRegion;
					OrderBLL.ShipPostalCode = order.ShipPostalCode;
					OrderBLL.ShipCountry = order.ShipCountry;
					OrderBLL.OrderStatus = order.OrderStatus;
					OrderBLL.ProductID = order.ProductID;
					OrderBLL.ProductName = order.ProductName;
					OrderBLL.Quantity = order.Quantity;
					OrderBLL.UnitPrice = Convert.ToDouble(order.UnitPrice);
					OrderBLL.Discount = Convert.ToDouble(order.Discount);

					Data.AddOrderDetails(OrderBLL);

					//После успешного обновления заказа, пользователя перенаправляют на главную страницу
					return RedirectToAction("Index");
				}
				else return View(order);
			}
			catch(ValidationException ex)
			{
				return Content(ex.Message);
			}
		}