public string EditCalendarEvent(CalendarEventsPostDto newCalendarEvent) { var calendarEventToUpdate = this.bmsData.CalendarEvents.Find(newCalendarEvent.Id); var creator = this.bmsData.Users.Find(newCalendarEvent.CreatorId); calendarEventToUpdate.Title = newCalendarEvent.Title; calendarEventToUpdate.Description = newCalendarEvent.Description; calendarEventToUpdate.StartTime = newCalendarEvent.StartDate; calendarEventToUpdate.EndTime = newCalendarEvent.EndDate; calendarEventToUpdate.Creator = creator; calendarEventToUpdate.Color = newCalendarEvent.Color; this.bmsData.CalendarEvents.Update(calendarEventToUpdate); this.bmsData.SaveChanges(); return($"Event {newCalendarEvent.Title} was successfully updated!"); }
public string CreateCalendarEvent(CalendarEventsPostDto newCalendarEvent) { var userSrv = new UserService(bmsData); var calendarEvent = new CalendarEvent() { EventId = newCalendarEvent.Id, Title = newCalendarEvent.Title, Description = newCalendarEvent.Description, Color = newCalendarEvent.Color, StartTime = newCalendarEvent.StartDate, EndTime = newCalendarEvent.EndDate, CreatorId = newCalendarEvent.CreatorId, ProjectId = newCalendarEvent.ProjectId, }; this.bmsData.CalendarEvents.Add(calendarEvent); this.bmsData.SaveChanges(); return($"Event {newCalendarEvent.Title} was created!"); }
private void HandleSaveCommand(object parameter) { var result = string.Empty; try { var newCalendarEvent = new CalendarEventsPostDto() { Id = this.Id, CreatorId = this.creatorId, ProjectId = this.SelectedProject.Id, Title = this.Title, Description = this.Description, StartDate = this.StartDate, EndDate = this.EndDate, Color = this.SelectedColor, }; if (this.SelectedCalendarEvent == null) { result = this.CalendarEventService.CreateCalendarEvent(newCalendarEvent); MessageBox.Show(result); this.RedirectToMainCalendarEvents(); } else { result = this.CalendarEventService.EditCalendarEvent(newCalendarEvent); MessageBox.Show(result); this.RedirectToMainCalendarEvents(); } } catch (Exception e) { result = e.Message; MessageBox.Show(result); } }