Exemplo n.º 1
0
        public async Task <ActionResult> UpdateProduct(ProductDto productDto, int id)
        {
            Product product = await _dataContext.Products.FindAsync(id);

            if (product == null)
            {
                return(BadRequest("Product does not exist"));
            }

            ConvertDtosToEntities.ConvertProduct(ref product, productDto);

            _dataContext.Products.Update(product);

            await _dataContext.SaveChangesAsync();

            return(Ok());
        }
Exemplo n.º 2
0
        public async Task <ActionResult> ModifyPersonalInfo(NameAndSurnameDto nameAndSurnameDto)
        {
            AppUser user = await _dataContext.AppUsers.Include(x => x.PersonalData.Adress).FirstOrDefaultAsync(x => x.Id == getIdFromClaims().Value);

            if (user == null)
            {
                return(Unauthorized("User does not exist"));
            }

            ConvertDtosToEntities.ConvertUserNameAndSurname(ref user, nameAndSurnameDto);

            _dataContext.AppUsers.Update(user);

            await _dataContext.SaveChangesAsync();

            return(Ok());
        }