Пример #1
0
        public OperationResultVo <Guid> Update(ArquivoViewModel viewModel)
        {
            OperationResultVo <Guid> result;

            try
            {
                Arquivo model;

                // TODO validate before

                Arquivo existing = _repository.GetById(viewModel.Id);
                if (viewModel.Id == Guid.Empty || existing == null)
                {
                    return(new OperationResultVo <Guid>("Erro ao atualizar Arquivo"));
                }

                model = _mapper.Map(viewModel, existing);

                _repository.Update(model);

                _unitOfWork.Commit();

                result = new OperationResultVo <Guid>(model.Id);
            }
            catch (Exception ex)
            {
                result = new OperationResultVo <Guid>(ex.Message);
            }

            return(result);
        }