public IActionResult SaveEvent(Event eventModel, List <string> NotificationForUserIds)
        {
            if (ModelState.IsValid)
            {
                eventModel.EndTime = EventHelper.CalculateDate(eventModel.StartTime, eventModel.Duration, eventModel.DurationType);
                _queries.AddEvent(eventModel, NotificationForUserIds);
                return(RedirectToAction("Events"));
            }
            List <User> users = _queries.GetAllUsers();

            ViewBag.AllUsers = users;
            return(View("CreateEvent"));
        }
Beispiel #2
0
 private void Button_Click_8(object sender, RoutedEventArgs e)
 {
     if (datePickerCalendar.SelectedDate != null)
     {
         if (cbEventType.SelectedItem != null)
         {
             if (textBoxEventCaption.Text == "" || textBoxEventPlace.Text == "" || (textBoxEventCaption.Text == "" && textBoxEventPlace.Text == ""))
             {
                 MessageBox.Show("Нужно указать данные о мероприятии");
             }
             else
             {
                 if (_bIsNewEvent == true)
                 {
                     QueriesManager.Execute(Queries.AddEvent(textBoxEventCaption.Text, textBoxEventPlace.Text, textBoxEventDescription.Text,
                                                             GIVM.LoadID(Queries.GetEventTypeID(cbEventType.SelectedItem.ToString()), "id"), datePickerCalendar.SelectedDate.Value));
                 }
                 else
                 {
                     Events EvE = (Events)listViewEvents.SelectedItems[0];
                     QueriesManager.Execute(Queries.UpdateEvent(textBoxEventCaption.Text, textBoxEventPlace.Text, textBoxEventDescription.Text,
                                                                GIVM.LoadID(Queries.GetEventTypeID(cbEventType.SelectedItem.ToString()), "id"), datePickerCalendar.SelectedDate.Value,
                                                                GIVM.LoadID(Queries.GetEventID(EvE.Caption), "id_event")));
                 }
                 gridNewEvent.Visibility      = Visibility.Hidden;
                 textBoxEventCaption.Text     = "";
                 textBoxEventPlace.Text       = "";
                 cbEventType.SelectedItem     = null;
                 listViewEvents.ItemsSource   = EVM.LoadEvents(Queries.GetEventsList(_iYear, _iSemestr));
                 textBlockEventInfo.Text      = textBoxEventDescription.Text;
                 textBoxEventDescription.Text = "";
             }
         }
         else
         {
             MessageBox.Show("Нужно указать тип мероприятия");
         }
     }
     else
     {
         MessageBox.Show("Нужно указать дату мероприятия");
     }
 }