// POST api/inventory
        //public HttpResponseMessage Post(List<order> ords)
        public events Post(events evt)
        {
            //DetailsRepository.saveAll(ords);
            DetailsRepository.saveAll(evt);

            var sessionFactory = FluentNHibernate.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                // retreive all stores and display them
                using (session.BeginTransaction())
                {
                    evt = session.Load<events>(evt.id);

                    IList<order> ord = evt.orderList.ToList();

                    foreach (order o in ord)
                    {
                        o.orderEvent = null;
                    }

                }
            }

            return evt;
            //string msg = "Items updated";
            //var response = Request.CreateResponse(HttpStatusCode.Created, evt);
            //string url = Url.Link("DefaultApi", new { evt.id });
            //response.Headers.Location = new Uri(url);
            //return response;
        }
Exemple #2
0
        public static string loadlistEvent(events evt)
        {
            System.Text.StringBuilder SB = new System.Text.StringBuilder();
            SB.Append("select ");
            SB.Append(" [order].truck, events.eventName, events.eventDate, [order].checkOut, [order].available As Avl ");
            SB.Append(" , bom.component, sum(bom.qty * [order].orderQty) As LoadQty ");
            SB.Append(" from events ");
            SB.Append(" inner join [order] on [order].orderEvent_id = events.id ");
            SB.Append(" inner join bom on bom.item = [order].item ");
            //SB.Append(string.Format(" where truck = '{0}' ", Truck));
            SB.Append(string.Format(" where events.id = {0} ", evt.id));
            SB.Append(" group by [order].truck, events.eventName, events.eventDate, [order].checkout, [order].available ");
            SB.Append(" , bom.component");

            return(SB.ToString());
        }
Exemple #3
0
        public static string loadlistEvent(events evt)
        {
            System.Text.StringBuilder SB = new System.Text.StringBuilder();
            SB.Append("select ");
            SB.Append(" [order].truck, events.eventName, events.eventDate, [order].checkOut, [order].available As Avl ");
            SB.Append(" , bom.component, sum(bom.qty * [order].orderQty) As LoadQty ");
            SB.Append(" from events ");
            SB.Append(" inner join [order] on [order].orderEvent_id = events.id ");
            SB.Append(" inner join bom on bom.item = [order].item ");
            //SB.Append(string.Format(" where truck = '{0}' ", Truck));
            SB.Append(string.Format(" where events.id = {0} ", evt.id));
            SB.Append(" group by [order].truck, events.eventName, events.eventDate, [order].checkout, [order].available ");
            SB.Append(" , bom.component");

            return SB.ToString();
        }
        public static IList<loadlist> GetLoadList(events evt)
        {
            SQLiteCommand cmd = new SQLiteCommand(new SQLiteConnection());

            cmd.Connection.ConnectionString = string.Format("data source={0}", FluentNHibernate.DbFile);

            cmd.CommandText = sql.loadlistEvent(evt);

            cmd.Connection.Open();

            SQLiteDataReader rdr = cmd.ExecuteReader();

            IList<loadlist> loadList = new List<loadlist>();

            while (rdr.Read())
            {
                loadList.Add(
                    new loadlist
                    {
                        Avl = Convert.ToInt64(rdr["Avl"].ToString())
                       ,
                        component = rdr["component"].ToString()
                       ,
                        checkOut = Convert.ToDateTime(rdr["checkOut"].ToString())

                        ,
                        eventDate = Convert.ToDateTime(rdr["eventDate"].ToString())
                       ,
                        eventName = rdr["eventName"].ToString()
                       ,
                        LoadQty = Convert.ToInt64(rdr["LoadQty"].ToString())
                       ,
                        truck = rdr["truck"].ToString()

                    });
            }

            return loadList;
        }
 public IList<loadlist> Post(events evt)
 {
     return LoadListRepository.GetLoadList(evt);
 }
Exemple #6
0
        internal static void Save(events eventOrder)
        {
            // create our NHibernate session factory
            var sessionFactory = FluentNHibernate.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {

                // retreive all stores and display them
                using (var transaction = session.BeginTransaction())
                {

                    session.SaveOrUpdate(eventOrder);

                    transaction.Commit();

                }

            }
        }
Exemple #7
0
        internal static void InsertEvent(ref events Event)
        {
            // create our NHibernate session factory
            var sessionFactory = FluentNHibernate.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {

                // retreive all stores and display them
                using (var transaction = session.BeginTransaction())
                {

                    session.SaveOrUpdate(Event);

                    transaction.Commit();

                    //Event.id = myEvent.id;

                }

            }
        }
Exemple #8
0
        public static void saveAll(events evt)
        {
            // create our NHibernate session factory
            var sessionFactory = FluentNHibernate.CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                // retreive all stores and display them
                using (session.BeginTransaction())
                {

                    foreach (order o in evt.orderList)
                    {
                        o.checkin = evt.checkIn;
                        o.checkout = evt.checkOut;
                        o.orderEvent = evt;
                    }

                    session.SaveOrUpdate(evt);

                    /*
                    foreach (order ord in ords)
                    {
                        session.Update(ord);
                    }
                    */

                    session.Transaction.Commit();

                    InventoryAvailability.Set(evt.id);

                }

            }
        }
Exemple #9
0
        // POST api/student
        public HttpResponseMessage Post(events Event)
        {
            string msg = "";
            if (Event.eventDate > Event.checkIn)
            {
                msg = "Check In: " + Event.checkIn.ToShortDateString() + " before event Date: " + Event.eventDate.ToShortDateString() + "?";
            }
            else if (Event.checkOut > Event.eventDate)
            {
                msg = "Check Out: " + Event.checkOut.ToShortDateString() + " after event Date: " + Event.eventDate.ToShortDateString() + "?";
            }

            if (msg.Length > 0)
            {
                var response = Request.CreateResponse(HttpStatusCode.InternalServerError, msg);
                string url = Url.Link("DefaultApi", new { msg });
                response.Headers.Location = new Uri(url);
                return response;
            }
            else
            {
                EventsRepository.InsertEvent(ref Event);
                var response = Request.CreateResponse(HttpStatusCode.Created, Event);
                string url = Url.Link("DefaultApi", new { Event.id });
                response.Headers.Location = new Uri(url);
                return response;
            }
        }