コード例 #1
0
        public void Insert()
        {
            using (var context = new CalendarContext(_credentials))
            {
                // add the calendar
                var calendar = new Data.Tables.Calendar();
                calendar.AuthorID = _credentials.UserID;
                calendar.Description = this.Description;
                calendar.Name = this.Name;
                context.Calendars.Add(calendar);
                context.SaveChanges();
                this.CalendarID = calendar.ID;

                // Sharing
                foreach (var invitee in _calendarInvitees)
                {
                    invitee.CalendarID = this.CalendarID;
                    context.CalendarInvitees.Add(invitee);
                }

                // add the history record
                var history = new CalendarHistory();
                history.CalendarID = this.CalendarID;
                history.TransactionDate = DateTime.Now;
                history.TransactionType = Data.Enumeration.CalendarHistoryType.Create;
                history.UserID = _credentials.UserID;
                context.CalendarHistory.Add(history);
                context.SaveChanges();
            }
        }
コード例 #2
0
        public void Update()
        {
            using (var context = new CalendarContext(_credentials))
            {
                // add the calendar
                var calendar = context.Calendars.Where(w => w.ID == this.CalendarID).First();
                calendar.AuthorID = _credentials.UserID;
                calendar.Description = this.Description;
                calendar.Name = this.Name;

                // update the invitees
                // check id's to update?

                // add the history record
                var history = new CalendarHistory();
                history.CalendarID = this.CalendarID;
                history.TransactionDate = DateTime.Now;
                history.TransactionType = Data.Enumeration.CalendarHistoryType.Edit;
                history.UserID = _credentials.UserID;
                context.CalendarHistory.Add(history);
                context.SaveChanges();
            }
        }