public EditableEventViewModel(IModelFacade facade, EventObject eventObject)
            : base(eventObject)
        {
            _facade = facade;
            this.AvailableWorkTypes = new ObservableCollection<TeacherWorkType>(_facade.GetAllWorkTypes(ViewModelLocator.CurrentTeacher.Id));

            this.OkButtonText = "Зберегти";
            this.SelectedWorkKind = eventObject.TeacherWorkKind;
            _isNewEvent = false;
        }
 public void InsertOrUpdate(EventObject scheduledevent)
 {
     if (scheduledevent.Id == default(int)) {
         // New entity
         Context.ScheduledEvents.Add(scheduledevent);
     } else {
         // Existing entity
         Context.Entry(scheduledevent).State = EntityState.Modified;
     }
 }
        public void UpdateEvent(EventObject eventObject)
        {
            // Get repo.
            var repo = App.DefaultInjectionService.Get<IScheduledEventRepository>();

            // Insert once.
            repo.InsertOrUpdate(eventObject);

            // Save.
            repo.SaveAllChanges();
            repo.Dispose();
        }
        public void AddEvent(int teacherId, EventObject eventObject)
        {
            // Get repo.
            var repo = App.DefaultInjectionService.Get<IScheduledEventRepository>();

            // Insert once.
            repo.InsertOrUpdate(eventObject);

            if (eventObject.IsRepeat)
            {
                // Repeative object.
                DateTime date = eventObject.StartDateTime;
                while (date <= eventObject.EndDateTime || date <= _maxDate)
                {
                    // Repeat.
                    var eventRepeatObject = new EventObject();
                    eventRepeatObject.Importance = eventObject.Importance;
                    eventRepeatObject.Place = eventObject.Place;
                    eventRepeatObject.IsRepeat = true;
                    eventRepeatObject.RepeatDaysInterval = eventObject.RepeatDaysInterval;
                    eventRepeatObject.StartDateTime = date;
                    eventRepeatObject.EndDateTime = eventObject.EndDateTime;
                    eventRepeatObject.TeacherWorkKindId = eventObject.TeacherWorkKindId;
                    eventRepeatObject.Title = eventObject.Title;
                    eventRepeatObject.CalendarId = eventObject.CalendarId;
                    eventRepeatObject.Description = eventObject.Description;

                    repo.InsertOrUpdate(eventRepeatObject);
                    date = date.AddDays(eventObject.RepeatDaysInterval);
                }
            }

            // Save.
            repo.SaveAllChanges();
            repo.Dispose();
        }
예제 #5
0
 public EventViewModelBase(EventObject eventObject)
 {
     // Fill all general parameters.
     EventObject = eventObject;
 }
예제 #6
0
 public EventContainer(EventObject eventObject)
     : base(eventObject)
 {
     // Fill all specific parameters.
     this.LeftIndex = 0;
 }
 public ScheduledEventViewModel(EventObject eventObject)
     : base(eventObject)
 {
 }