예제 #1
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                Admin.Models.Events.Events eve = new Admin.Models.Events.Events();
                var eventList = new List<Admin.Models.Events.Events>();
                var dte = (collection.Get("date1")).ToString();
               // dte=DateTime.Parse(HttpContext.IsPostNotification.Equals("CreatedAt").ToString());
                 var date2 = (DateTime.Parse(dte)).ToString("d");
                model.CreateEvent(collection.Get("EventTitle"), collection.Get("EventDescription"),date2);
            //    var today = DateTime.Today.ToShortDateString();
              //  var differnce = DateTime.Parse(dte).Subtract(DateTime.Parse(today));
               // ViewData["Timeleft"] = differnce;

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
예제 #2
0
        public Events GetDetails(int id)
        {
            Events eve = new Events();
            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                sqlConn.Query = "select Calender_Event_ID,Title,Description,CreatedAt,EventDate from tbl_Calender_Event where Calender_Event_ID=@id";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Command.Parameters.AddWithValue("@id", id);
                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    while (sqlConn.Reader.Read())
                    {
                        eve.Calender_Event_ID = Int32.Parse(sqlConn.Reader["Calender_Event_ID"].ToString());
                        eve.EventTitle = sqlConn.Reader["Title"].ToString();
                        eve.EventDescription = sqlConn.Reader["Description"].ToString();
                        eve.CreatedAt=DateTime.Parse(sqlConn.Reader["CreatedAt"].ToString());
                        eve.EventDate = sqlConn.Reader["EventDate"].ToString();

                    }
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }

            return eve;
        }
예제 #3
0
        public List<Events> GetAllEvents()
        {
            SQLManager.SQLManager sqlConn = new SQLManager.SQLManager();
            Events eve = new Events();
            var eventList = new List<Events>();
            try
            {
                sqlConn.Connection = new SqlConnection(sqlConn.ConnectionString);
                sqlConn.Query = "select Calender_Event_ID,Title,Description,CreatedAt,EventDate from tbl_Calender_Event ORDER BY CASE WHEN ISDATE (EventDate)=1 THEN CONVERT(Datetime,EventDate,101) ELSE null END ASC";
                sqlConn.Command = new SqlCommand(sqlConn.Query, sqlConn.Connection);
                sqlConn.Connection.Open();

                using (sqlConn.Reader = sqlConn.Command.ExecuteReader())
                {
                    while (sqlConn.Reader.Read())
                    {
                        eventList.Add(new Admin.Models.Events.Events
                        {
                            Calender_Event_ID = Int32.Parse(sqlConn.Reader["Calender_Event_ID"].ToString()),
                            EventTitle = sqlConn.Reader["Title"].ToString(),
                            EventDescription = sqlConn.Reader["Description"].ToString(),
                            CreatedAt=DateTime.Parse(sqlConn.Reader["CreatedAt"].ToString()),
                            EventDate = sqlConn.Reader["EventDate"].ToString(),

                        });
                    }
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                if (sqlConn.Reader != null)
                    sqlConn.Reader.Close();
                sqlConn.Connection.Close();
                sqlConn.Connection.Dispose();

            }

            return eventList;
        }