Esempio n. 1
0
        // Gets item from db by Id
        public static CalendarDomainItem GetCalendarItem(int id)
        {
            CalendarDomainItem item = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.CalendarData_SelectById"
                                    , inputParamMapper : delegate(SqlParameterCollection commentsCollection)
            {
                commentsCollection.AddWithValue("@Id", id);
            }, map : delegate(IDataReader reader, short set)
            {
                item = MapCalendar(reader);
            });
            return(item);
        }
Esempio n. 2
0
        // Mapping the item. Using DRY methodology.
        public static CalendarDomainItem MapCalendar(IDataReader reader)
        {
            CalendarDomainItem item = new CalendarDomainItem();
            int startingindex       = 0;

            item.Id          = reader.GetInt32(startingindex++);
            item.Title       = reader.GetString(startingindex++);
            item.Location    = reader.GetString(startingindex++);
            item.Description = reader.GetString(startingindex++);
            item.StartTime   = reader.GetDateTime(startingindex++);
            item.EndTime     = reader.GetDateTime(startingindex++);
            item.Date        = reader.GetDateTime(startingindex++);

            return(item);
        }
Esempio n. 3
0
        // Gets List of Items in db
        public static List <CalendarDomainItem> GetCalendarItemList()
        {
            List <CalendarDomainItem> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.CalendarData_SelectAll",
                                    inputParamMapper : null, map : delegate(IDataReader reader, short set)
            {
                CalendarDomainItem item = MapCalendar(reader);

                if (list == null)
                {
                    list = new List <CalendarDomainItem>();
                }
                list.Add(item);
            }
                                    );
            return(list);
        }
Esempio n. 4
0
        // Gets List of Items in db
        public static List <CalendarDomainItem> GetCalendarItemListByDate(DateTime Date)
        {
            List <CalendarDomainItem> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.CalendarData_SelectByDate",
                                    inputParamMapper : delegate(SqlParameterCollection commentsCollection)
            {
                commentsCollection.AddWithValue("@Date", Date);
            }, map : delegate(IDataReader reader, short set)
            {
                CalendarDomainItem item = MapCalendar(reader);

                if (list == null)
                {
                    list = new List <CalendarDomainItem>();
                }
                list.Add(item);
            }
                                    );
            return(list);
        }