public static void Auth(string login, string password) { ConnectionSettings.Login = login; ConnectionSettings.Password = password; using (var service = new AimpService()) { var response = service.Auth(); if (response.Error) { throw new Exception(response.Message); } if (response.UserRights.Any(x => x == UserRightsCollection.Admin.Id)) { IsAdd = true; IsAdmin = true; IsView = true; IsDelete = true; } else { if (response.UserRights.Any(x => x == UserRightsCollection.Add.Id)) { IsAdd = true; } if (response.UserRights.Any(x => x == UserRightsCollection.Delete.Id)) { IsDelete = true; } if (response.UserRights.Any(x => x == UserRightsCollection.View.Id)) { IsView = true; } } } }
private void _Settings(int?id) { using (var service = new AimpService()) { var response = service.GetClientReport(id); if (id == null) { ClientReport = new ClientReport(); _clientReportDocument = new ClientReportDocument(); _clientReport = new ClientReport(); ClientBankStatus = new ObservableCollection <ClientBankStatusViewModel>(response.Banks .Select(x => new ClientBankStatusViewModel() { Bank = x, BankStatuses = response.BankStatuses, SelectedBankStatus = response.BankStatuses.FirstOrDefault() })); } else { ClientReport = response.Document.BankReportClients.First().ClientReport; _clientReport = TinyMapper.Map <ClientReport>(ClientReport); ClientReport.ClientStatus = response.ClientStatuses.FirstOrDefault(x => x.Id == ClientReport.ClientStatus?.Id); ClientReport.CreditProgramm = response.CreditProgramms.FirstOrDefault(x => x.Id == ClientReport.CreditProgramm?.Id); _clientReportDocument = response.Document; var clientBankStatuses = (from bRep in response.Banks join bClient in response.Document.BankReportClients on bRep.Id equals bClient.Bank.Id into bankDefault from bClient in bankDefault.DefaultIfEmpty() select new { bClient?.Id, Enabled = bClient != null ? true : false, Bank = bRep, BankStatus = bClient?.BankStatus }) .Select(x => new ClientBankStatusViewModel() { Id = x.Id != null ? (int)x.Id : 0, Bank = x.Bank, Enable = x.Enabled, BankStatuses = response.BankStatuses, SelectedBankStatus = response.BankStatuses.FirstOrDefault(y => y.Id == x.BankStatus?.Id) }); ClientBankStatus = new ObservableCollection <ClientBankStatusViewModel>(clientBankStatuses); } ClientStatuses = new ObservableCollection <ClientStatus>(response.ClientStatuses); CreditProgramms = new ObservableCollection <CreditProgramm>(response.CreditProgramms); } }
public CardTrancportViewModel(int?id) { using (var service = new AimpService()) { if (id != null) { var response = service.GetCardTrancport((int)id); if (response.Error) { throw new Exception(response.Message); } _document = response.Document; CardTrancport = response.Document.CardTrancport; _cardTrancportForCompare = TinyMapper.Map <CardTrancport>(CardTrancport); var preChecks = response.Document.PreChecks.Select(x => new PreCheckCardTrancportViewModel() { CardTrancportId = x.Id, Date = x.Date, Enable = true, Name = x.Name, Paid = x.Paid, Card = x.Card, PriceForClient = x.PriceForClient, Summ = x.Summ }); PreCheks = new ObservableCollection <PreCheckCardTrancportViewModel>(preChecks); } else { _document = new CardTrancportDocument(); CardTrancport = new CardTrancport(); _cardTrancportForCompare = new CardTrancport(); PreCheks = new ObservableCollection <PreCheckCardTrancportViewModel>(); } var responseStatuses = service.GetStatusesCard(); if (responseStatuses.Error) { throw new Exception(responseStatuses.Message); } CardTrancport.StatusCardTrancport = responseStatuses.Items.FirstOrDefault(x => x.Id == CardTrancport.StatusCardTrancport?.Id); StatusesCardTrancport = new ObservableCollection <StatusCardTrancport>(responseStatuses.Items); } }
public static void GetAndOpen(int id) { try { using (AimpService service = new AimpService()) { var file = service.GetUserFile(id); if (file.Error) { MessageBox.Show(file.Message); return; } Open(file.UserFile.Name, file.UserFile.File); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Не удалось открыть файл"); } }