Exemplo n.º 1
0
        public async Task <IHttpActionResult> GetMandate(string email, string mobileno)
        {
            //1. Authorize Request
            if (!IsAuthorized())
            {
                _logger.Warn($"{ nameof(this.GetMandate)} Unauthorised user");
                return(Unauthorized());
            }

            var model = new MandateAccountModel
            {
                Email        = email,
                MobileNumber = mobileno
            };
            var result = SmartContractManager.GetMandate(model);

            return(Ok(result));
        }
Exemplo n.º 2
0
        public async Task <MandateModel> GetMandate(MandateAccountModel model)
        {
            //1. Create user object
            var user = new User
            {
                Email        = model.Email,
                MobileNumber = model.MobileNumber
            };

            var mandate = new MandateModel
            {
                Email        = model.Email,
                MobileNumber = model.MobileNumber
            };

            //2. Get Smart Meter Mandate
            var smartMet = await SmartContractService.GetSmartMandate(user);

            if (!string.IsNullOrEmpty(smartMet))
            {
                var smartMandateType = JsonConvert.DeserializeObject <MandateType>(smartMet);
                mandate.SmartMeter = smartMandateType;
            }

            //3. Get Source Profile Mandate
            var smartPro = await SmartContractService.GetProfileMandate(user);

            if (!string.IsNullOrEmpty(smartPro))
            {
                var proMandateType = JsonConvert.DeserializeObject <MandateType>(smartPro);
                mandate.SourceProfile = proMandateType;
            }

            //3. Get Trusted Party Mandate
            var trustPar = await SmartContractService.GetTrustedMandate(user);

            if (!string.IsNullOrEmpty(trustPar))
            {
                var trustMandateType = JsonConvert.DeserializeObject <MandateType>(trustPar);
                mandate.SourceProfile = trustMandateType;
            }

            return(mandate);
        }