public ClientViewModel(INavigationService navigationService)
 {
     try
     {
         _navigationService = navigationService;
         ClientInfo         = new ClientModel();
         var getTypesTask = Task.Factory.StartNew(() => GetClientTypes());
         Types = new ObservableCollection <ClientTypeModel>(getTypesTask.Result.Result);
         var task = Task.Factory.StartNew(() => server.GetClientsIdsAsync());
         ClientsIds = new ObservableCollection <string>(task.Result.Result);
         InitializeCommands();
         SaveClientCommand = new RelayCommand(() =>
         {
             //ClientInfo.ClientTypeId = ClientTypeId;
             ClientDto model = ClientInfo.ToDto();
             if (ClientID == null)
             {
                 server.AddClientAsync(model);
             }
             else
             {
                 server.UpdateClientAsync(ClientID, ClientInfo.ToDto());
             }
         });
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         Debug.WriteLine(ex.InnerException);
     }
 }
Пример #2
0
 public async Task <ClientDto> AddClient(ClientModel model)
 {
     return(await crm.AddClientAsync(model.ToDto()));
 }