Ejemplo n.º 1
0
        public override async Task <int> HandleCommand(UpdateCommand request, CancellationToken cancellationToken)
        {
            if (request.Employee == null || request.Employee.Id == 0 || request.Employee.EmployeeId == 0)
            {
                throw new BusinessException("AddWrongInformation");
            }

            var collectionEmployee = (await collectionEmployeeQueries.Gets($"id = {request.Employee.Id}")).FirstOrDefault();

            if (collectionEmployee != null)
            {
                collectionEmployee.EmployeeId = request.Employee.EmployeeId;
                var rs = await collectionEmployeeRepository.Update(collectionEmployee);

                return(rs == 0 ? 0 : throw new BusinessException("Common.UpdateFail"));
            }

            // CollectionEmployee isn't exsited. Of course, we don't need update it.
            return(0);
        }