Beispiel #1
0
        public async Task<IHttpActionResult> AddHiveSectionCategoryProduct([FromBody] UpdateHiveSectionCategoryProduct createRequest)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            await _hiveSectionProductsService.AddHiveSectionCategoryProductAsync(createRequest);
            return ResponseMessage(Request.CreateResponse(HttpStatusCode.NoContent));
        }
        /// <inheritdoc/>
        public async Task AddHiveSectionCategoryProductAsync(UpdateHiveSectionCategoryProduct createRequest)
        {
            StoreItem newItem = new StoreItem();

            newItem.Id            = _context.Items.Max(i => i.Id) + 1;
            newItem.ProductId     = createRequest.Id;
            newItem.Quantity      = createRequest.Quantity;
            newItem.HiveSectionId = createRequest.HiveSectionId;

            _context.Items.Add(newItem);

            await _context.SaveChangesAsync();
        }