Beispiel #1
0
        public async Task <bool> Do(RegisterTermEvent message)
        {
            try
            {
                Term term = _unitOfWork.termRepository.Get(message.Id);
                if (term != null)
                {
                    term.AssignDescription(message.Description);
                    term.AssignIsActive(message.IsActive);
                    term.AssignIsDeleted(message.IsDeleted);
                    term.AssignModifiedDate(DateTime.Now);
                    term.IncreaseRowVersion();
                    term.AssignTitle(message.Title);
                    term.AssignCourse(message.CourseId);

                    _unitOfWork.termRepository.Update(term);
                    await _unitOfWork.CommitAsync();

                    return(true);
                }
                Term newTerm = Term.CreateInstance(null, message.Title, message.CourseId, message.IsActive, message.Description);

                await _unitOfWork.termRepository.AddAsync(newTerm);

                await _unitOfWork.CommitAsync();

                return(true);
            }
            catch (Exception)
            {
                _unitOfWork.Dispose();
                return(false);
            }
        }