Ejemplo n.º 1
0
        public int CreateRegistrant(RegistrantModel registrant)
        {
            var registrantEntity = new RegistrantDbRepoModel();

            using (_unitOfWork.Add <RegistrantDbRepoModel>())
            {
                registrantEntity = _mapper.Map <RegistrantDbRepoModel>(registrant);

                _unitOfWork.GetRepository <RegistrantDbRepoModel>().AddItem(registrantEntity);
                _unitOfWork.Save();
            }

            return(registrantEntity.Id);
        }
Ejemplo n.º 2
0
        public RegistrantDbRepoModel GetRegistrantById(int id, bool includeWallets = false)
        {
            var registrantEntity = new RegistrantDbRepoModel();

            using (_unitOfWork.Add <RegistrantDbRepoModel>().Add <WalletDbRepoModel>())
            {
                if (includeWallets)
                {
                    registrantEntity = _unitOfWork.GetRepository <RegistrantDbRepoModel>().Get(reg => reg.Id == id, null, "CountryRelation").FirstOrDefault();
                    var wallets = _unitOfWork.GetRepository <WalletDbRepoModel>().Get(wallet => wallet.RegistrantId == registrantEntity.Id, null, "Status").ToList();
                    registrantEntity.Wallets = wallets;
                }
                else
                {
                    registrantEntity = _unitOfWork.GetRepository <RegistrantDbRepoModel>().Get(reg => reg.Id == id, null, "CountryRelation").FirstOrDefault();
                }
            }

            return(registrantEntity);
        }