コード例 #1
0
        public async Task Create(Contract.Production production)
        {
            try
            {
                production.ProductionId = await GetNewProductionId();

                await _productions.InsertOneAsync(production);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddArea(Contract.Production request)
        {
            try
            {
                await _areaRepository.Add(request);

                return(Ok(request));
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
コード例 #3
0
        public async Task <IActionResult> UpdateArea(Contract.Production request)
        {
            try
            {
                await _areaRepository.Update(request);

                _logService.SendMessagesAsync("ProductionAreaChanged");
                return(Ok(request));
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
コード例 #4
0
        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));
        }
コード例 #5
0
 /// <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;
         }
     }
 }
コード例 #6
0
 /// <summary>
 /// Update a production
 /// </summary>
 /// <param name="model">Production model</param>
 public Task Update(Contract.Production model)
 {
     throw new System.NotImplementedException();
 }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
 /// <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);
     }
 }
コード例 #9
0
 public async Task Create(Contract.Production production)
 {
     await _productionRepository.Create(production);
 }