Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PutCustOrder(string id, CustOrder custOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != custOrder.CustID)
            {
                return(BadRequest());
            }

            db.Entry(custOrder).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustOrderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PostCustOrder(CustOrder custOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CustOrders.Add(custOrder);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CustOrderExists(custOrder.CustID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = custOrder.CustID }, custOrder));
        }
 public void Add(CustOrder t)
 {
     if (t != null)
     {
         context.CustOrders.Add(mapper.Map(t));
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public void AddPizzaOrder(CustOrder o)
 {
     if (o != null)
     {
         context.Add(mapper.Map(o));
         context.SaveChanges();
     }
 }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> GetCustOrder(string id)
        {
            CustOrder custOrder = await db.CustOrders.FindAsync(id);

            if (custOrder == null)
            {
                return(NotFound());
            }

            return(Ok(custOrder));
        }
Ejemplo n.º 6
0
 public OrderReviewViewModel()
 {
     OrderParts       = new CompareOrderViewModel();
     Customer         = new Customer();
     Order            = new CustOrder();
     ContactDropdown  = new List <CustomerContactDropdown>();
     Tags             = new List <Tag>();
     EmployeeDropdown = new List <EmployeeDropdown>();
     Currencies       = new List <Currency>();
     Carriers         = new List <CustomerCarrier>();
     this.PriceCad    = new PricingCADModel();
 }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> DeleteCustOrder(string id)
        {
            CustOrder custOrder = await db.CustOrders.FindAsync(id);

            if (custOrder == null)
            {
                return(NotFound());
            }

            db.CustOrders.Remove(custOrder);
            await db.SaveChangesAsync();

            return(Ok(custOrder));
        }
Ejemplo n.º 8
0
 public IActionResult Post([FromBody] CustOrder x) //model binder of asp.net core will look for this parameter from request body
 {
     if (x == null)
     {
         return(BadRequest("The CustOrder you are trying to add is empty"));
     }
     else
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         else
         {
             repo.Add(x);
             return(CreatedAtAction(nameof(Get), new { id = x.Id }, x));
         }
     }
 }
 // BA never used
 public void RemoveOrder(CustOrder order)
 {
     repo.Delete(order);
     repo.SaveChanges();
 }
 // BA never used
 public void AddOrder(CustOrder order)
 {
     repo.Add(order);
     repo.SaveChanges();
 }
        //Get SO information from PeachTree
        public static List <CustOrder> getSalesOrderInfo(String _salesOrder)
        {
            String         salesOrder = _salesOrder;
            String         connString = System.Configuration.ConfigurationManager.ConnectionStrings["PeachreeSNOConnectionString"].ToString();
            DataTable      order      = new DataTable();
            DataTable      orderItem  = new DataTable();
            OdbcConnection cn; //= new OdbcConnection(connString);

            var result = new List <CustOrder>();


            order     = new DataTable(); //reset
            orderItem = new DataTable(); //reset
            //Peachtree

            using (cn = new OdbcConnection(connString))
            {
                string      sqlCheck = @"
                        SELECT        Reference, CONVERT(TransactionDate, SQL_CHAR) AS TDate, Description,  ShipToName, ShipToAddress1, ShipToAddress2, ShipToCity, ShipToState, ShipToZIP, ShipToCountry, ShipVia, CustomerInvoiceNo ,POSOisClosed
                        FROM          JrnlHdr
                        WHERE         Reference = '" + salesOrder + "' AND (JrnlHdr.Module <> 'R')";
                OdbcCommand sqlCmd   = new OdbcCommand(sqlCheck, cn);
                //                sqlCmd.Parameters.Add("?", OdbcType.VarChar).Value = (rec.ServiceId.ToString() + "-" + rec.OrderId.ToString());
                OdbcDataAdapter adapter = new OdbcDataAdapter(sqlCmd);
                adapter.Fill(order);
            }

            using (cn = new OdbcConnection(connString))
            {
                string      sqlCheck = @"
                        SELECT        ItemID, ItemDescription, SUM(QTY) AS QTY
                        FROM          (SELECT        LineItem.ItemID, LineItem.ItemDescription, CONVERT(JrnlRow.Quantity, SQL_INTEGER) AS QTY
                        FROM            JrnlRow, LineItem, JrnlHdr
                        WHERE        JrnlRow.ItemRecordNumber = LineItem.ItemRecordNumber 
                                     AND JrnlRow.PostOrder = JrnlHdr.PostOrder 
                                     AND(JrnlHdr.Reference = '" + salesOrder + "') AND(JrnlRow.Quantity > 0) AND(JrnlHdr.Module <> 'R')) view1 GROUP BY ItemID, ItemDescription";
                OdbcCommand sqlCmd   = new OdbcCommand(sqlCheck, cn);
                //                sqlCmd.Parameters.Add("?", OdbcType.VarChar).Value = (rec.ServiceId.ToString() + "-" + rec.OrderId.ToString());
                OdbcDataAdapter adapter = new OdbcDataAdapter(sqlCmd);
                adapter.Fill(orderItem);
            }

            String   orderNo           = "";
            DateTime date              = new DateTime();
            String   description       = "";
            String   billTo            = "";
            String   ShipToAddress1    = "";
            String   ShipToAddress2    = "";
            String   ShipToCity        = "";
            String   ShipToState       = "";
            String   ShipToZIP         = "";
            String   ShipToCountry     = "";
            String   ShipVia           = "";
            String   CustomerInvoiceNo = "";
            String   POSOisClosed      = "";

            var sb = new StringBuilder();

            foreach (DataRow row in order.Rows)
            {
                var arr = row.ItemArray.Select(i => i.ToString()).ToArray();
                orderNo           = arr[0];
                date              = Convert.ToDateTime(arr[1]);;
                description       = arr[2];
                billTo            = arr[3];
                ShipToAddress1    = arr[4];
                ShipToAddress2    = arr[5];
                ShipToCity        = arr[6];
                ShipToState       = arr[7];
                ShipToZIP         = arr[8];
                ShipToCountry     = arr[9];
                ShipVia           = arr[10];
                CustomerInvoiceNo = arr[11];
                POSOisClosed      = arr[12];
            }

            var sbItem = new StringBuilder();

            foreach (DataRow row in orderItem.Rows)
            {
                CustOrder orderInfo = new CustOrder();
                var       arr       = row.ItemArray.Select(i => i.ToString()).ToArray();
                orderInfo.Sales_Order = orderNo;
                orderInfo.Description = arr[1];
                orderInfo.Bill_to     = description;
                orderInfo.Date        = date;
                orderInfo.Ship_to_Address_Line_One = billTo + "\n" + ShipToAddress1;
                orderInfo.Ship_to_City             = ShipToCity;
                orderInfo.Ship_to_State            = ShipToState;
                orderInfo.Ship_to_Zipcode          = ShipToZIP;
                orderInfo.Ship_to_Country          = ShipToCountry;
                orderInfo.Ship_Via    = ShipVia;
                orderInfo.Customer_PO = CustomerInvoiceNo;
                orderInfo.Closed      = POSOisClosed.Equals("1") ? true : false;;

                orderInfo.Item_ID  = arr[0];
                orderInfo.Quantity = Convert.ToInt32(arr[2]);

                result.Add(orderInfo);
            }
            cn.Close();
            return(result);
        }