/// <summary>
        /// Christian Lopez
        ///
        /// Created:
        /// 2017/04/13
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static CompanyOrderWithLines RetrieveOrderWithLinesByOrderId(int orderId)
        {
            CompanyOrderWithLines order = null;

            try
            {
                CompanyOrder data = RetrieveOrderByOrderId(orderId);
                order = new CompanyOrderWithLines()
                {
                    CompanyOrderID = data.CompanyOrderID,
                    EmployeeId     = data.EmployeeId,
                    SupplierId     = data.SupplierId,
                    Amount         = data.Amount,
                    HasArrived     = data.HasArrived,
                    OrderDate      = data.OrderDate,
                    Active         = data.Active,
                    OrderLines     = RetrieveCompanyOrderLinesByOrderId(orderId)
                };
            }
            catch (Exception)
            {
                throw;
            }

            return(order);
        }
        /// <summary>
        /// Christian Lopez
        ///
        /// Created:
        /// 2017/04/13
        ///
        /// Retrieves bundled order and lines for a supplier id
        /// </summary>
        /// <param name="supplierId"></param>
        /// <returns></returns>
        public static List <CompanyOrderWithLines> RetrieveCompanyOrdersWithLinesBySupplierId(int supplierId)
        {
            List <CompanyOrderWithLines> orders = new List <CompanyOrderWithLines>();

            try
            {
                List <CompanyOrder> data = RetrieveCompanyOrdersBySupplierId(supplierId);
                foreach (CompanyOrder c in data)
                {
                    CompanyOrderWithLines newOrder = new CompanyOrderWithLines()
                    {
                        CompanyOrderID = c.CompanyOrderID,
                        EmployeeId     = c.EmployeeId,
                        SupplierId     = c.SupplierId,
                        OrderDate      = c.OrderDate,
                        Amount         = c.Amount,
                        HasArrived     = c.HasArrived,
                        Active         = c.Active,
                        OrderLines     = RetrieveCompanyOrderLinesByOrderId(c.CompanyOrderID)
                    };
                    orders.Add(newOrder);
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(orders);
        }
예제 #3
0
 /// <summary>
 /// Ariel Sigo
 ///
 /// Created:
 /// 2017/04/29
 ///
 /// GET: CompanyOrderWithLines/Details/5
 /// </summary>
 /// <param name="id"></param>
 /// <returns>View of Company order with lines if successful, error if not.</returns>
 public ActionResult Details(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     try
     {
         CompanyOrderWithLines companyOrderWithLines = _companyOrderManager.RetrieveCompanyOrderWithLinesById((int)id);
         if (companyOrderWithLines == null)
         {
             return(HttpNotFound());
         }
         return(View(companyOrderWithLines));
     }
     catch (Exception)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable));
     }
 }
예제 #4
0
        public ActionResult InvoiceDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CompanyOrderWithLines companyOrder = null;

            try
            {
                companyOrder = _companyOrderManager.RetrieveCompanyOrderWithLinesById((int)id);
            }
            catch (Exception)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable));
            }

            if (null == companyOrder)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }

            return(View("Invoice", companyOrder));
        }