public async Task <IActionResult> Create(string lawnId, ProductApplicationForCreate newProductApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var application = await _productApplicationService.CreateAsync(lawnId, newProductApplication);

            return(CreatedAtAction(nameof(Get), new { productApplicationId = application.Id }, new ProductApplication(application)));
        }
Exemplo n.º 2
0
        public async Task <Models.ProductApplication> CreateAsync(string lawnId, ProductApplicationForCreate newProductApplication)
        {
            var application = new Models.ProductApplication
            {
                ProductId       = newProductApplication.ProductId,
                LawnId          = lawnId,
                LawnSectionId   = newProductApplication.LawnSectionId,
                Amount          = newProductApplication.Amount,
                UnitOfMeasure   = newProductApplication.UnitOfMeasure,
                ApplicationDate = newProductApplication.ApplicationDate,
                CreatedDate     = DateTime.UtcNow,
                UpdatedDate     = DateTime.UtcNow
            };

            await _productApplications.InsertOneAsync(application);

            return(application);
        }