public void Add() { if (!IsEdit) { newMission.Name = Name; newMission.Description = Description; newMission.StartTime = StartTime; newMission.EndTime = EndTime; newMission.MissionTypeId = SelectedMissionType?.Id; SelectedTeams = ActualTeams.ToList(); string x = MissionService.Add(newMission); if (x == null) { MissionService.SetObserversToMission(newMission.Observers, MissionService.GetAll().Last().Id); TryClose(); } else { Error = x; } } else { toEdit.Name = Name; toEdit.Description = Description; toEdit.StartTime = StartTime; toEdit.EndTime = EndTime; toEdit.MissionTypeId = SelectedMissionType?.Id; SelectedTeams = ActualTeams.ToList(); string x = MissionService.Edit(toEdit); if (x == null) { MissionService.SetObserversToMission(toEdit.Observers, toEdit.Id); TryClose(); } else { Error = x; } } }