Example #1
0
        static public async Task <bool> createUser(User user, string password)
        {
            RestController <User> userController = new RestController <User>();
            var list = await userController.getObjects(WcfConfig.getUserUrl(user.Email));

            if (list.Count != 0)
            {
                return(false);
            }

            RestController <Role>    roleController    = new RestController <Role>();
            RestController <Patient> patientController = new RestController <Patient> ();

            List <Role> roles = await roleController.getObjects(WcfConfig.getRole(RolesKind.PATIENT));

            user.Roles = roles;

            IBuffer buff = CryptographicBuffer.ConvertStringToBinary(password, BinaryStringEncoding.Utf8);
            HashAlgorithmProvider hap = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);
            IBuffer shaBuff           = hap.HashData(buff);

            byte[] pass;
            CryptographicBuffer.CopyToByteArray(shaBuff, out pass);
            user.Pass = pass;
            await userController.insertObject(user, WcfConfig.TableUser);

            await patientController.insertObject(new Patient { Pesel = user.Pesel }, WcfConfig.TablePatient);

            return(true);
        }
Example #2
0
        public static async void AddMeasure(LifeFuncMeasure measure)
        {
            string pesel = UserController.getUserPesel();
            RestController <Patient>         cont     = new RestController <Patient>();
            RestController <LifeFuncMeasure> contMeas = new RestController <LifeFuncMeasure> ();
            List <Patient> list = await cont.getObjects(WcfConfig.getPatient(pesel));

            measure.PatientId = list.First().Id;
            await contMeas.insertObject(measure, WcfConfig.TableMeasure);
        }