public void Handle(CreateInternationalAffiliationLocation command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var location = new InternationalAffiliationLocation
            {
                InternationalAffiliationId = command.AffiliationId,
                PlaceId            = command.PlaceId,
                CreatedByPrincipal = command.Principal.Identity.Name,
                CreatedOnUtc       = DateTime.UtcNow
            };

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

            _entities.Create(location);

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

            command.CreatedInternationalAffiliationLocation = location;
        }
        public void Handle(UpdateInternationalAffiliationLocation command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            /* Retrieve the affiliation location to update. */
            var target = _entities.Get <InternationalAffiliationLocation>().Single(a => a.RevisionId == command.Id);

            if (target == null)
            {
                string message = String.Format("AffiliationLocation Id {0} not found.", command.Id);
                throw new Exception(message);
            }

            var updateExpertise = new InternationalAffiliationLocation
            {
                PlaceId = command.PlaceId,
            };

            if (target.Equals(updateExpertise))
            {
                return;
            }

            /* Update fields */
            target.PlaceId            = command.PlaceId;
            target.UpdatedOnUtc       = command.UpdatedOn.ToUniversalTime();
            target.UpdatedByPrincipal = command.Principal.Identity.Name;

            _entities.Update(target);

            if (!command.NoCommit)
            {
                _unitOfWork.SaveChanges();
            }
        }
 protected bool Equals(InternationalAffiliationLocation other)
 {
     return(PlaceId == other.PlaceId);
 }
 protected bool Equals(InternationalAffiliationLocation other)
 {
     return PlaceId == other.PlaceId;
 }