protected override async Task ImportAsync(IDataService data, Icon newValue) { var icon = await data.FetchOneAsync <Icon>(i => i.Path == newValue.Path); if (icon != null) { if (newValue.Foreground.HasValue) { icon.Foreground = newValue.Foreground; } if (newValue.SourceXaml != null) { icon.SourceXaml = newValue.SourceXaml; } if (newValue.SourceSvg != null) { icon.SourceSvg = newValue.SourceSvg; } await data.UpdateAsync(icon, "Foreground", "SourceXaml", "SourceSvg"); } else { await data.AddAsync <Icon>(i => { i.Path = newValue.Path; i.Foreground = newValue.Foreground; i.SourceXaml = newValue.SourceXaml; i.SourceSvg = newValue.SourceSvg; }); } }
private async Task <Connection> GetConnection(User user) { if (user == null) { return(null); } return(await Data.AddAsync <Connection>(c => { try { var identity = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split('\\'); c.Account = identity.Length > 1 ? identity[1] : identity[0]; c.Domain = identity.Length > 1 ? identity[0] : ""; } catch (NotSupportedException) { } c.Exe = System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName ?? "Unknown"; c.Framework = Environment.Version.ToString(); c.Workstation = Environment.MachineName; c.Notify = 0; c.Os = Environment.OSVersion.VersionString; c.UserId = user.Id; c.Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); c.X64 = Environment.Is64BitProcess; }).ConfigureAwait(false)); }
public async Task <Guid> Create(UserRegisterDto userRegisterDto) { var user = userBuilder.Build(userRegisterDto); await userDataService.AddAsync(user); return(user.Id); }
protected override async Task ImportAsync(IDataService data, Icon newValue) { var done = false; var icons = data.FetchWhereAsync <Icon>(e => e.Path == newValue.Path); await foreach (var icon in icons) { icon.SourceXaml = newValue.SourceXaml; icon.SourceSvg = newValue.SourceSvg; icon.Foreground = newValue.Foreground; await data.UpdateAsync(icon, "SourceXaml", "SourceSvg", "Foreground"); done = true; } if (!done) { await data.AddAsync <Icon>(icon => { icon.SourceXaml = newValue.SourceXaml; icon.SourceSvg = newValue.SourceSvg; icon.Foreground = newValue.Foreground; }); } }
protected override async Task ImportAsync(IDataService data, LocalizeEntry importValue) { var e = await data.FetchOneAsync <LocalizeEntry>(e => e.Tag == importValue.Tag && e.Code == importValue.Code && e.Custom == importValue.Custom); try { if (e != null) { if (e.Value == importValue.Value && e.Todo == false) { return; } e.Value = importValue.Value; e.Todo = false; e.Custom = importValue.Custom; await data.UpdateAsync(e, "Value", "Todo", "Custom"); } else { await data.AddAsync <LocalizeEntry>(i => { i.Tag = importValue.Tag; i.Code = importValue.Code; i.Value = importValue.Value; i.Todo = false; i.Custom = importValue.Custom; }); } } catch (Exception ex) { } }
private static void SeedWithSampleUsers(this IDataService <User> dataService) { var users = dataService.GetAllAsync() .Result; foreach (var user in users) { dataService.RemoveAsync(user) .Wait(); } dataService.AddAsync(Admin) .Wait(); dataService.AddAsync(User) .Wait(); }
public void Register(string tag, string code, string value, bool quality) { var entry = _db.AddAsync <LocalizeEntry>(e => { e.Tag = tag; e.Code = code; e.Value = value; e.Todo = !quality; }); }
private static void SeedWithSampleAnimals(this IDataService <Animal> dataService) { var animalsFromRepo = dataService.GetAllAsync() .Result; foreach (var animal in animalsFromRepo) { dataService.RemoveAsync(animal) .Wait(); } var animals = new[] { new Animal { AnimalType = "Cat", BDate = DateTime.Today, Description = "Кошка картошка", Id = Guid.NewGuid(), Name = "Пуговка", Sex = Sex.Female, UserId = User.Id }, new Animal { AnimalType = "Cat", BDate = DateTime.Today - TimeSpan.FromDays(30), Description = "Кот обормот", Id = Guid.NewGuid(), Name = "Вася", Sex = Sex.Male, UserId = Admin.Id }, new Animal { AnimalType = "Cat", BDate = DateTime.Today, Description = "Спокойная кошка", Id = Guid.NewGuid(), Name = "Маруся", Sex = Sex.Female, UserId = Admin.Id } }; foreach (var animal in animals) { dataService.AddAsync(animal) .Wait(); } }
public async Task AggregateAnalysisAsync([ActivityTrigger] FileAnalysisResult analysisResult, ILogger log) { if (analysisResult != null) { await _dataService.AddAsync(analysisResult); } else { log.LogError($"Analysis result is empty, cannot insert record."); } }
private async Task SaveCustomerAsync(object customer) { if (Customers.Any(str => String.Compare(str.Email, SelectedCustomer.Email, true) == -1)) { ButtonEnabled = true; await Task.Run(() => _customerDataService.AddAsync(SelectedCustomer)); ButtonEnabled = false; await GetAllCustomersAsync(); } return; }
public async Task <Guid> Create(AnimalSaveDto animalSaveDto, UserDto userDto) { var files = animalSaveDto.Files .Select(f => new { FileDTO = f, File = fileBuilder.Build(f) }) .ToArray(); await Task.WhenAll(files.Select(f => fileStorageService.Save( new MemoryStream(Convert.FromBase64String(f.FileDTO.FileInBase64)), f.File.WayToFile))); var animal = animalBuilder.Build(animalSaveDto, files.Select(f => f.File) .ToArray(), userBuilder.Build(userDto)); await animalDataService.AddAsync(animal); return(animal.Id); }
public async Task SetValueAsync <T>(string name, T value, int?userId) { var o = await _data.FetchOneAsync <Option>(e => e.Name == name && e.UserId == userId).ConfigureAwait(false); if (o == null) { o = await _data.AddAsync <Option>(e => { e.Name = name; e.UserId = userId; e.Value = value.ToString(); }).ConfigureAwait(false); return; } o.Value = value.ToString(); await _data.SaveAsync(o).ConfigureAwait(false); }
private async Task SaveCustomerAsync(object customer) { if (SelectedOrder != null) { ButtonEnabled = true; if (SelectedOrder.Id.ToString() == NullObjectId) { await Task.Run(() => _orderDataService.AddAsync(SelectedOrder)); ButtonEnabled = false; } else { await Task.Run(() => _orderDataService.UpdateAsync(SelectedOrder)); } ButtonEnabled = false; } return; }
public async Task Run([BlobTrigger("excel-files/{name}", Connection = "")] Stream excelFile, string name, Uri uri, ILogger log) { log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {excelFile.Length} Bytes"); var isValidFileExtension = _fileExtensionValidationService.IsValidExtension(uri); if (isValidFileExtension) { var excelFileContent = _excelFileContentExtractorService.GetFileContent(excelFile); if (excelFileContent != null) { await _dataService.AddAsync(excelFileContent); } } else { log.LogError($"Extension of uploaded file {name} is not supported. Supported extensions are: {SupportedFileTypes.XLS} and {SupportedFileTypes.XLSX}"); } }
public async Task <IActionResult> CreateNewDataAsync(string name) { var collection = await _settings.FindCollectionAsync(name); var data = HttpContext.Request.Form.ToJToken(collection.Schema); var(valid, errors) = await _data.ValidateAsync(name, data); if (!valid) { ViewData["Errors"] = errors; return(View("ItemNew", new EditViewModel { CollectionName = name, Schema = new CMSSchema(collection.Schema), Data = data })); } var id = await _data.AddAsync(name, data); return(RedirectToAction(nameof(Item), new { name, id })); }
public async Task <Guid> AddGameAsync(AddGameInput input) { var gameExists = context .All <Wishlist>() .Any(w => w.CustomerId == currentUser.CustomerId && w.GameId == input.GameId); if (gameExists) { return(input.GameId); } var wishlist = new Wishlist { GameId = input.GameId, CustomerId = currentUser.CustomerId }; await context.AddAsync(wishlist); await context.SaveAsync(); return(input.GameId); }
public async Task <ActionResult <Series> > Post(Series series) { var insertedTag = await dataService.AddAsync <Series, SeriesBusiness>(series); return(Ok(insertedTag)); }
public async Task <ActionResult <Exercise> > Post(Exercise workout) { var insertedExercise = await dataService.AddAsync <Exercise, ExcersiseBusiness>(workout); return(Ok(insertedExercise)); }
public async Task <ProductLocation> AddNewAsync(ProductLocation productLocation) { var newProductLocationResult = await _dataService.AddAsync(productLocation); return(newProductLocationResult); }
public async Task <ActionResult <Workout> > Post(Workout workout) { var insertedWorkout = await dataService.AddAsync <Workout, WorkoutBusiness>(workout); return(Ok(insertedWorkout)); }
private async Task <WebApiResponseRecord> ProcessInvoiceRecord(WebApiRequestRecord webApiRequestRecord, WebApiResponseRecord webApiResponseRecord) { var formUrl = webApiRequestRecord.Data["formUrl"] as string; _log.LogInformation($"{ServiceConstants.FormAnalyzerServiceName} - Got form URL: {formUrl}"); var analysisResult = await ProcessInvoiceDocumentContent(formUrl); webApiResponseRecord.Data = new Dictionary <string, object>(); var invoiceData = new InvoiceData(); if (analysisResult.documentResults != null) { var documents = analysisResult.documentResults; foreach (var documentResult in documents) { var documentFields = documentResult.fields; if (documentFields != null) { if (documentFields.Charges != null) { webApiResponseRecord.Data.Add(documentFields.Charges.fieldName, documentFields.Charges.text); invoiceData.Charges = documentFields.Charges.text; } else { _log.LogWarning($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get field: 'Charges' for the form with URL: {formUrl}"); } if (documentFields.ForCompany != null) { webApiResponseRecord.Data.Add(documentFields.ForCompany.fieldName, documentFields.ForCompany.text); invoiceData.ForCompany = documentFields.ForCompany.text; } else { _log.LogWarning($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get field: 'ForCompany' for the form with URL: {formUrl}"); } if (documentFields.FromCompany != null) { webApiResponseRecord.Data.Add(documentFields.FromCompany.fieldName, documentFields.FromCompany.text); invoiceData.FromCompany = documentFields.FromCompany.text; } else { _log.LogWarning($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get field: 'FromCompany' for the form with URL: {formUrl}"); } if (documentFields.InvoiceDate != null) { webApiResponseRecord.Data.Add(documentFields.InvoiceDate.fieldName, documentFields.InvoiceDate.text); invoiceData.InvoiceDate = documentFields.InvoiceDate.text; } else { _log.LogWarning($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get field: 'InvoiceDate' for the form with URL: {formUrl}"); } if (documentFields.InvoiceDueDate != null) { webApiResponseRecord.Data.Add(documentFields.InvoiceDueDate.fieldName, documentFields.InvoiceDueDate.text); invoiceData.InvoiceDueDate = documentFields.InvoiceDueDate.text; } else { _log.LogWarning($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get field: 'InvoiceDueDate' for the form with URL: {formUrl}"); } if (documentFields.InvoiceNumber != null) { webApiResponseRecord.Data.Add(documentFields.InvoiceNumber.fieldName, documentFields.InvoiceNumber.text); invoiceData.InvoiceNumber = documentFields.InvoiceNumber.text; } else { _log.LogWarning($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get field: 'InvoiceNumber' for the form with URL: {formUrl}"); } if (documentFields.VatID != null) { webApiResponseRecord.Data.Add(documentFields.VatID.fieldName, documentFields.VatID.text); invoiceData.VatID = documentFields.VatID.text; } else { _log.LogWarning($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get field: 'VatID' for the form with URL: {formUrl}"); } } else { _log.LogError($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get any fields from the form with URL: {formUrl}"); } } } else { _log.LogError($"{ServiceConstants.FormAnalyzerServiceName} - Cannot get any document results from the form with URL: {formUrl}"); } await _dataService.AddAsync(invoiceData); return(webApiResponseRecord); }
public async Task <ActionResult <WorkoutItem> > Post(WorkoutItem WorkoutItem) { var insertedWorkoutItem = await dataService.AddAsync <WorkoutItem, WorkoutItemBusiness>(WorkoutItem); return(Ok(insertedWorkoutItem)); }
public async Task <TBEntity> AddAsync(TBEntity entity) { return(Map(await _dataService.AddAsync(Map(entity)))); }
public async Task <Product> AddNewAsync(Product product) { var newProductResult = await _dataService.AddAsync(product); return(newProductResult); }
public async Task <ActionResult <Tag> > Post(Tag workout) { var insertedTag = await dataService.AddAsync <Tag, TagBusiness>(workout); return(Ok(insertedTag)); }