示例#1
0
        public Event Add(Event obj, Guid idOwner, Guid idLocal)
        {
            Player owner = _unitOfWork.PlayerRepository.GetById(idOwner);

            if (owner == null)
            {
                throw new Exception("Owner não encontrado.");
            }

            Local local = _unitOfWork.LocalRepository.GetById(idLocal);

            if (local == null)
            {
                throw new Exception("Local não encontrado.");
            }

            obj.Validate();

            obj.AddOwner(owner);
            obj.AddLocal(local);

            _unitOfWork.BeginTransaction();
            _unitOfWork.EventRepository.Add(obj);
            _unitOfWork.Commit();

            return(obj);
        }
示例#2
0
        public Owner Save(Owner obj)
        {
            obj.Validate();

            _unitOfWork.BeginTransaction();
            _unitOfWork.OwnerRepository.Add(obj);
            _unitOfWork.Commit();

            return(obj);
        }
示例#3
0
        public Local Add(Local obj, Guid idOwner)
        {
            Owner owner = _unitOfWork.OwnerRepository.GetById(idOwner);

            if (owner == null)
            {
                throw new Exception("Owner não encontrado.");
            }

            obj.Validate();

            obj.AddOwner(owner);

            _unitOfWork.BeginTransaction();
            _unitOfWork.LocalRepository.Add(obj);
            _unitOfWork.Commit();

            return(obj);
        }