public Models.ContractTransaction CreateProfile(Models.Profile profile) { var _profile = ModelProfileToServceProfile(profile); var result = client.createProfile(_profile); var citizenProfile = ServiceProfileToModelProfile(_profile); Models.ContractTransaction transaction = prepareDeployObject(citizenProfile); return(transaction); }
private Models.ContractTransaction prepareDeployObject(Models.Profile citizenProfile) { Models.ConstructorConfirmation _deployConfirmation = new Models.ConstructorConfirmation() { NewContractOrTokenId = Guid.NewGuid().ToString(), Name = "Smart Contract instance by ESC Template", TransactionConfirmation = new Models.TransactionConfirmation() { BlockHash = "0xfa4e2a31506c1f930efc7701ff6ddc1451d08a38a7a9267fe263766b4c7ea2d0", BlockNumber = "1", LedgerAddress = "", TransactionHash = "", Name = "Fake Contract", ProxyId = "Fake Contract_Proxy ID", TransactionIndex = "1" } }; Models.ContractTransaction _txInformation = new Models.ContractTransaction(citizenProfile, _deployConfirmation); return(_txInformation); }
private static Messages.Profile ModelProfileToServceProfile(Models.Profile profile) { Mapper.Reset(); Mapper.Initialize(cfg => cfg.CreateMap <Models.Profile, Messages.Profile>() .ForPath(d => d.BasicProfile.Name, o => o.MapFrom(s => s.BasicProfile.Name)) .ForPath(d => d.BasicProfile.DateOfBirth, o => o.MapFrom(s => Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(s.BasicProfile.DateOfBirth))) .ForPath(d => d.BasicProfile.FullAddress.Street, o => o.MapFrom(s => s.BasicProfile.Address.Street)) .ForPath(d => d.BasicProfile.FullAddress.City, o => o.MapFrom(s => s.BasicProfile.Address.City)) .ForPath(d => d.BasicProfile.FullAddress.State, o => o.MapFrom(s => s.BasicProfile.Address.State.ToUpper() == "NY" ? Messages.State.Ny : Messages.State.Nj)) .ForPath(d => d.BasicProfile.FullAddress.Zip, o => o.MapFrom(s => s.BasicProfile.Address.Zip)) .ForPath(d => d.BasicProfile.FedIncome, o => o.MapFrom(s => s.BasicProfile.FedIncome)) .ForPath(d => d.BasicProfile.StateIncome, o => o.MapFrom(s => s.BasicProfile.StateIncome)) .ForPath(d => d.BasicProfile.ApplicationType, o => o.MapFrom(s => s.BasicProfile.ApplicationType == Models.ApplicationType.Indivisual ? Messages.ApplicationType.Individual : Messages.ApplicationType.Family)) .ForPath(d => d.BasicProfile.Citizenship, o => o.MapFrom(s => s.BasicProfile.CitizenShip)) .ForPath(d => d.CurrentHealthcarePlan.EnrollmentBrokerAssignedState, o => o.MapFrom(s => s.CurrentHealthcarePlan.EnrollmentBorkerAssigedState.ToUpper() == "NY" ? Messages.State.Ny : Messages.State.Nj)) .ForPath(d => d.TransactionId, o => o.MapFrom(s => s.TransactionID ?? " ")) .ForPath(d => d.TransactedTime, o => o.MapFrom(s => Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(s.TransactedTime))) .ForPath(d => d.EnrolledHealthInsurance, o => o.MapFrom(s => s.CurrentHealthcarePlan.Plan.Name == null ? false : true)) ); Messages.Profile profileDTO = Mapper.Map <Messages.Profile>(profile); return(profileDTO); }
public ActionResult <ContractTransaction> CreateProfile([FromBody] Healthcare.BC.Offchain.Repository.Models.Profile CitizenProfile) { var transaction = _client.CreateProfile(CitizenProfile); return(transaction); }