Пример #1
0
        public string Put([FromForm] FormEditObject form)
        {
            bool editSucces = false;
            bool emailExist = false;

            bool[] array      = new bool[2];
            string JsonString = string.Empty;
            string oldemail   = form.oldemail;
            int    postcode   = 0;

            int.TryParse(form.postcode, out postcode);

            User user = new User(form.email, form.password, form.naam, form.voornaam, form.country, form.adres, postcode);

            user.password = EncryptionTool.Crypt(user.password);

            //kijken of veld leeg is
            if (user.naam == null || user.voornaam == null || user.emailadres == null || user.adres == null || user.postcode == 0 ||
                user.country == null || user.password == null)
            {
            }
            else
            {
                editSucces = true;
                var dt = EntityData.User.GetEmail(user.emailadres);
                //kijken of email al bestaat
                if (dt.Rows.Count > 0)
                {
                    string email2 = dt.Rows[0][0].ToString();
                    if (user.emailadres.Equals(email2))
                    {
                        emailExist = true;
                    }
                }
                else
                {
                    emailExist = false;
                    EntityData.Edit.Update(user, oldemail);
                }
            }
            //bools returnen
            array[0]   = editSucces;
            array[1]   = emailExist;
            JsonString = JsonConvert.SerializeObject(array);
            return(JsonString);
        }
Пример #2
0
        public string Post([FromForm] FormEditObject form)
        {
            string email      = form.email;
            string JsonString = string.Empty;
            User   user       = new User();
            var    dt         = EntityData.Edit.Get(email);

            if (dt.Rows.Count > 0)
            {
                user.emailadres = dt.Rows[0][0].ToString();
                string encryptedPassword = dt.Rows[0][1].ToString();
                user.password = EncryptionTool.Decrypt(encryptedPassword);
                user.naam     = dt.Rows[0][2].ToString();
                user.voornaam = dt.Rows[0][3].ToString();
                user.country  = dt.Rows[0][4].ToString();
                user.adres    = dt.Rows[0][5].ToString();
                user.postcode = Convert.ToInt32(dt.Rows[0][6]);
            }
            JsonString = JsonConvert.SerializeObject(user);

            return(JsonString);
        }