public void Add()
 {
     if (!IsEdit)
     {
         string x = MissionTypeService.Add(Type);
         if (x == null)
         {
             TryClose();
         }
         else
         {
             Error = x;
         }
     }
     else
     {
         toEdit.Name = Type;
         string x = MissionTypeService.Edit(toEdit);
         if (x == null)
         {
             TryClose();
         }
         else
         {
             Error = x;
         }
     }
 }
Пример #2
0
        public AddMissionViewModel(MissionDTO mission)
        {
            IsEdit         = true;
            ButtonLabel    = "Edit";
            MissionTypes   = MissionTypeService.GetAllBindableCollection();
            AvailableTeams = new BindableCollection <TeamDTO>(TeamService.GetAll().Where(x => x.MissionId == null).ToList());
            ActualTeams    = new BindableCollection <TeamDTO>(TeamService.GetAll().Where(x => x.MissionId == mission.Id).ToList());

            int i = 0;

            while (ActualType == null)
            {
                if (MissionTypes[i].Id == mission.MissionTypeId)
                {
                    ActualType = i;
                    break;
                }
                else
                {
                    i++;
                }
            }

            this.toEdit = mission;
            Name        = mission.Name;
            Description = mission.Description;
            StartTime   = mission.StartTime;
            EndTime     = mission.EndTime;
            NotifyOfPropertyChange(() => Name);
            NotifyOfPropertyChange(() => Description);
            NotifyOfPropertyChange(() => StartTime);
            NotifyOfPropertyChange(() => EndTime);
        }
Пример #3
0
 public AddMissionViewModel()
 {
     IsEdit         = false;
     ButtonLabel    = "Add";
     MissionTypes   = MissionTypeService.GetAllBindableCollection();
     AvailableTeams = new BindableCollection <TeamDTO>(TeamService.GetAll().Where(x => x.MissionId == null).ToList());
     ActualTeams    = new BindableCollection <TeamDTO>();
     StartTime      = DateTime.Now;
     newMission     = new MissionDTO();
     NotifyOfPropertyChange(() => StartTime);
 }
        public void Delete(MissionTypeDTO missionType)
        {
            IWindowManager manager             = new WindowManager();
            DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel();
            bool?showDialogResult = manager.ShowDialog(modify, null, null);

            if (showDialogResult != null && showDialogResult == true)
            {
                MissionTypeService.Delete(missionType);
            }
            Reload();
        }
 public void Reload()
 {
     MissionTypes = MissionTypeService.GetAll();
     NotifyOfPropertyChange(() => MissionTypes);
 }