コード例 #1
0
        /// <summary>
        /// GetWithOrderLines() build a DTOobject list and returns a complete order with orderlines and total amount calculated
        /// </summary>
        /// <param name="paramOrderID"></param>
        /// <returns>_orderlist</returns>
        public async Task <DTOOrderWithOrderLines> GetWithOrderLines(int paramOrderID)
        {
            // open async connection reader order get by order ID
            _dbManager.command.CommandText = "select * FROM tblOrders WHERE id=@paramOrderID";
            _dbManager.command.Parameters.Add("paramOrderID", SqlDbType.Int).Value = paramOrderID;
            await _dbManager.connection.OpenAsync();

            SqlDataReader reader = await _dbManager.command.ExecuteReaderAsync().ConfigureAwait(false);

            _order = _tblOrdersDBReader.ReadDB(reader).FirstOrDefault();
            _dbManager.connection.Close();

            // get lines from services
            var orderlines = await orderLinesService.GetBy(paramOrderID).ConfigureAwait(false);

            var customer = await customerService.GetBy(_order.CustomerId).ConfigureAwait(false);

            // break if customer is deleted
            if (customer.Zip == 1234)
            {
                return(null);
            }

            //build output
            _DTOOrderWithOrderLines = _DTOOrderWithOrderLinesBuilder.Build(customer, _order, orderlines);
            return(_DTOOrderWithOrderLines);
        }
コード例 #2
0
        public List <tblOrders> ReadDB(SqlDataReader reader)
        {
            while (reader.Read())
            {
                var order = new tblOrders();
                // FILL PROPERTIES

                order.Id         = reader.GetInt32(0);
                order.CustomerId = reader.GetInt32(1);
                order.CreateDate = reader.GetDateTime(2);
                orderslist.Add(order);
            }

            return(orderslist);
        }
コード例 #3
0
 public ActionResult Printorder(int id)
 {
     try
     {
         tblOrders tb = db.tblOrders.Where(i => i.Orderno == id).FirstOrDefault();
         ViewBag.Order = db.tblOrders.Where(i => i.Orderno == id).FirstOrDefault();
         int invoice_id = Convert.ToInt32(tb.Invoice_Id);
         ViewBag.invoice_number = invoice_id;
         int Address = Convert.ToInt16(tb.Address);
         ViewBag.address = db.tb_address.Where(i => i.ID == Address).FirstOrDefault();
     }
     catch
     {
     }
     return(View());
 }
コード例 #4
0
        public ActionResult updatestatus(FormCollection collect)
        {
            try
            {
                int       id = Convert.ToInt32(collect["Id"]);
                tblOrders tb = db.tblOrders.Where(i => i.Orderno == id).FirstOrDefault();
                tb.status = collect["status"];
                db.SaveChanges();

                ViewBag.Message = "Status Updated Successfully!!";
            }
            catch
            {
                ViewBag.Message = "Status NOT Updated!!";
            }
            return(Redirect("~/Vendor/orderview?Msg=" + ViewBag.Message));
        }
コード例 #5
0
        public DTOOrderWithTotal Build(tblCustomer paramCustomer, tblOrders paramOrder, List <DTOOrderlines> paramOrderlines)
        {
            // build total order amount
            Decimal ordertotal = 0;

            foreach (var item in paramOrderlines)
            {
                ordertotal += item.OrderlineTotal;
            }

            //build output
            _DTOOrderWithTotal = new DTOOrderWithTotal
            {
                CreateDate   = paramOrder.CreateDate,
                CustomerId   = paramOrder.CustomerId,
                CustomerName = paramCustomer.Firstname + " " + paramCustomer.Lastname,
                Id           = paramOrder.Id,
                OrderTotal   = ordertotal
            };
            return(_DTOOrderWithTotal);
        }
コード例 #6
0
        public DTOOrderWithOrderLines Build(tblCustomer paramCustomer, tblOrders paramOrder, List <DTOOrderlines> paramOrderlines)
        {
            // build total order amount
            Decimal ordertotal = 0;

            foreach (var item in paramOrderlines)
            {
                ordertotal += item.OrderlineTotal;
            }

            //build output
            _DTOOrderWithOrderLines = new DTOOrderWithOrderLines
            {
                CreateDate    = paramOrder.CreateDate,
                CustomerId    = paramOrder.CustomerId,
                Id            = paramOrder.Id,
                DTOOrderlines = paramOrderlines,
                OrderTotal    = ordertotal,
                customer      = paramCustomer
            };
            return(_DTOOrderWithOrderLines);
        }