Exemplo n.º 1
0
 protected bool Equals(LanguageExpertise other)
 {
     return((LanguageId.HasValue == other.LanguageId.HasValue) &&
            ((LanguageId.HasValue && other.LanguageId.HasValue && (LanguageId.Value == other.LanguageId.Value)) ||
             (!LanguageId.HasValue && !other.LanguageId.HasValue)) &&
            string.Equals(Dialect, other.Dialect) &&
            string.Equals(Other, other.Other) &&
            SpeakingProficiency == other.SpeakingProficiency &&
            ListeningProficiency == other.ListeningProficiency &&
            ReadingProficiency == other.ReadingProficiency &&
            WritingProficiency == other.WritingProficiency);
 }
Exemplo n.º 2
0
        public void Handle(CreateLanguageExpertise command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var person = _entities.Get <Person>().SingleOrDefault(p => p.User.Name == command.Principal.Identity.Name);

            if (person == null)
            {
                string message = string.Format("Person {0} not found.", command.Principal.Identity.Name);
                throw new Exception(message);
            }

            var expertise = new LanguageExpertise
            {
                PersonId             = person.RevisionId,
                LanguageId           = command.LanguageId,
                SpeakingProficiency  = command.SpeakingProficiency,
                ListeningProficiency = command.ListeningProficiency,
                ReadingProficiency   = command.ReadingProficiency,
                WritingProficiency   = command.WritingProficiency,
                Dialect = command.Dialect,
                Other   = command.Other,

                CreatedByPrincipal = command.Principal.Identity.Name,
                CreatedOnUtc       = DateTime.UtcNow
            };

            if (command.EntityId.HasValue)
            {
                expertise.EntityId = command.EntityId.Value;
            }

            _entities.Create(expertise);

            if (!command.NoCommit)
            {
                _unitOfWork.SaveChanges();
            }

            command.CreatedLanguageExpertise   = expertise;
            command.CreatedLanguageExpertiseId = command.CreatedLanguageExpertise.RevisionId;
        }