public async Task Create(Contract.Production production) { try { production.ProductionId = await GetNewProductionId(); await _productions.InsertOneAsync(production); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> AddArea(Contract.Production request) { try { await _areaRepository.Add(request); return(Ok(request)); } catch (Exception e) { return(BadRequest()); } }
public async Task <IActionResult> UpdateArea(Contract.Production request) { try { await _areaRepository.Update(request); _logService.SendMessagesAsync("ProductionAreaChanged"); return(Ok(request)); } catch (Exception e) { return(BadRequest()); } }
public void UpdateArea() { var mock = GetController(); var payload = new Contract.Production { ProductionId = Guid.NewGuid(), Restrictions = new List <string> { "Leite", "Soja" } }; mock.Setup(m => m.UpdateArea(payload)); }
/// <summary> /// Create document if not exists /// </summary> /// <param name="databaseName">database name</param> /// <param name="collectionName">collection name AKA table name</param> /// <param name="model">model</param> private async Task CreateDocumentIfNotExists(string databaseName, string collectionName, Contract.Production model) { try { await _document.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, model.ProductionId.ToString())); } catch (DocumentClientException de) { if (de.StatusCode == HttpStatusCode.NotFound) { await _document.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), model); } else { throw; } } }
/// <summary> /// Update a production /// </summary> /// <param name="model">Production model</param> public Task Update(Contract.Production model) { throw new System.NotImplementedException(); }
/// <summary> /// Add a production /// </summary> /// <param name="model">Production model</param> public async Task Add(Contract.Production model) { await ValidateDatabase(); await ValidateCollection(COLLECTION); await CreateDocumentIfNotExists(_nosql.Value.Database, COLLECTION, model); }
/// <summary> /// Update an existing document /// </summary> /// <param name="databaseName">database name</param> /// <param name="collectionName">collection name AKA table name</param> /// <param name="model"></param> /// <returns></returns> private async Task UpdateDocument(string databaseName, string collectionName, Contract.Production model) { try { var data = await _document.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, model.ProductionId.ToString())); } catch (DocumentClientException de) { Trace.WriteLine(de.Message); } }
public async Task Create(Contract.Production production) { await _productionRepository.Create(production); }