Beispiel #1
0
        /// <summary>
        /// Gets order by condition.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="date">The date.</param>
        /// <param name="oper">The operator.</param>
        /// <returns></returns>
        public List <OrderBE> GetByCondition(TTAEntityContainer dBEntity, string name, string startDate, string endDate)
        {
            List <Order> list          = new List <Order>();
            DateTime     startDateTime = DateTime.MinValue;
            DateTime     endDateTime   = DateTime.MaxValue;

            if (!startDate.Equals(string.Empty))
            {
                startDateTime = Convert.ToDateTime(startDate);
            }
            if (!endDate.Equals(string.Empty))
            {
                endDateTime = Convert.ToDateTime(endDate);
            }
            Status status = Status.Deleted;

            list = (from Order o in dBEntity.Orders where o.StatusId != (int)status && o.Customer.CustomerName.Contains(name) && o.CreatedDate >= startDateTime && o.CreatedDate <= endDateTime select o).ToList();

            List <OrderBE>  orderList  = new List <OrderBE>();
            OrderTranslator translator = new OrderTranslator();

            foreach (Order order in list)
            {
                OrderBE orderBE = translator.Translate(order);
                orderList.Add(orderBE);
            }
            return(orderList);
        }
Beispiel #2
0
 /// <summary>
 /// translate OrderDetails type to OrderDetailsBE type
 /// </summary>
 /// <param name="orderdetails"></param>
 /// <returns></returns>
 public OrderDetailsBE Translate(OrderDetails orderdetails)
 {
     if (orderdetails != null)
     {
         OrderDetailsBE orderdetailsBE = new OrderDetailsBE()
         {
             OrderDetailId = orderdetails.OrderDetailId,
             OrderId       = orderdetails.OrderId,
             ProductId     = orderdetails.ProductId,
             Quantity      = orderdetails.Quantity,
             TotalPrice    = orderdetails.TotalPrice,
             IsDeleted     = orderdetails.IsDeleted,
             Order         = new OrderTranslator().Translate(orderdetails.Order),
             Product       = new ProductTranslator().Translate(orderdetails.Product)
         };
         if (orderdetails.Order != null)
         {
             OrderTranslator orderTranslator = new OrderTranslator();
             orderdetailsBE.Order = orderTranslator.Translate(orderdetails.Order);
         }
         if (orderdetails.Product != null)
         {
             ProductTranslator productTranslator = new ProductTranslator();
             orderdetailsBE.Product = productTranslator.Translate(orderdetails.Product);
         }
         return(orderdetailsBE);
     }
     else
     {
         return(null);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Gets order by id.
        /// </summary>
        /// <param name="dBEntity">The entity frame work data entity.</param>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public OrderBE GetById(TTAEntityContainer dBEntity, int id)
        {
            Order           order      = null;
            OrderTranslator translator = new OrderTranslator();

            if (id >= 0)
            {
                order = (from Order o in dBEntity.Orders where o.OrderId == id select o).SingleOrDefault <Order>();
            }
            return(translator.Translate(order));
        }
Beispiel #4
0
        /// <summary>
        /// Inserts order.
        /// </summary>
        /// <param name="DBEntity">The TTAEntityContainer.</param>
        /// <param name="order">The order.</param>
        public OrderBE Insert(TTAEntityContainer DBEntity, OrderBE orderBE)
        {
            OrderTranslator translator = new OrderTranslator();
            Order           order      = null;

            if (orderBE != null)
            {
                order = translator.Translate(orderBE);
                DBEntity.AddToOrders(order);
                DBEntity.SaveChanges();
            }
            return(translator.Translate(order));
        }
Beispiel #5
0
        /// <summary>
        /// Gets the by customer ID.
        /// </summary>
        /// <param name="dBEntity">The d B entity.</param>
        /// <param name="customerId">The customer id.</param>
        /// <returns></returns>
        public List <OrderBE> GetByCustomerID(TTAEntityContainer dBEntity, int customerId)
        {
            List <Order>    orderList  = null;
            List <OrderBE>  resultList = null;
            OrderTranslator translator = new OrderTranslator();

            if (customerId >= 0)
            {
                orderList = (from Order o in dBEntity.Orders where o.CustomerId == customerId select o).ToList <Order>();
            }
            foreach (Order order in orderList)
            {
                OrderBE orderBE = translator.Translate(order);
                resultList.Add(orderBE);
            }
            return(resultList);
        }