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

            var checkEmployee = (await collectionEmployeeQueries.Gets($"collection_id = {request.Employee.CollectionId} and employee_id = {request.Employee.EmployeeId}")).FirstOrDefault();

            if (checkEmployee != null)
            {
                throw new BusinessException("Employee.NotExisted");
            }

            return(await collectionEmployeeRepository.Add(request.Employee) > 0 ? 0 : throw new BusinessException("Common.AddFail"));
        }