Esempio n. 1
0
        public async Task <IActionResult> Create([FromBody] ProductViewModel productDTO)
        {
            DateTime now = DateTime.UtcNow;

            Product product = new Product {
                Name = productDTO.Name
            };

            product.CreatedAt = now;
            product.CreatedBy = _userContext.FindByLogin(AuthentiationUtils.GetCurrentUserLoginByContext(Request.HttpContext));

            _context.Update(product);
            await _context.SaveChangesAsync();

            return(Json(ProductMapper.GetInstance().FromAToB(product)));
        }