public async Task <ActionResult <int> > UpdateSingleStatus(UpdateOrderStatusDTO orderToUpdate)
        {
            var existingOrder = await _orderRepository.SingleAsync(o => o.Id == orderToUpdate.Id);

            existingOrder.Status = orderToUpdate.Status;

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

            return(Ok(existingOrder.Id));
        }
Пример #2
0
        public async Task <ActionResult <int> > UpdateSingle([FromRoute] int id, UpdateUserDTO userToUpdate)
        {
            var existingUser = await _repository.GetSingleWithAddress(id);

            existingUser.Name     = userToUpdate.Name;
            existingUser.Phone    = userToUpdate.Phone;
            existingUser.Document = userToUpdate.Document;
            existingUser.Email    = userToUpdate.Email;

            if (existingUser.Address == null)
            {
                existingUser.Address = new Address();
            }

            existingUser.Address.Name    = userToUpdate.Address.Name;
            existingUser.Address.City    = userToUpdate.Address.City;
            existingUser.Address.State   = userToUpdate.Address.State;
            existingUser.Address.ZipCode = userToUpdate.Address.ZipCode;

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

            return(Ok(existingUser.Id));
        }