public bool AddChildContacts([FromBody] string[] emails)
        {
            //position 0 for user type : parent or child
            //position 1 will be for the user email itself
            if (emails[0].ToLower() != "child")
            {
                return(false);
            }
            string       userEmail = emails[1];
            userContacts contacts  = new userContacts
            {
                email  = userEmail,
                father = emails[2],
                mother = emails[3],
                friend = emails[4]
            };

            try
            {
                using (APP_DBEntities db = new APP_DBEntities())
                {
                    var userContacts = db.contacts
                                       .Where(b => b.email.Equals(contacts.email))
                                       .FirstOrDefault();
                    if (userContacts == null)
                    {
                        var userNewContacts = db.contacts.Add(contacts);
                        db.SaveChanges();
                        return(true);
                    }
                    userContacts.father = contacts.father;
                    userContacts.mother = contacts.mother;
                    userContacts.friend = contacts.friend;
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #2
0
 public bool CreateUser([FromBody] user user)
 {
     try
     {
         using (APP_DBEntities db = new APP_DBEntities())
         {
             db.users.Add(user);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool UpdateUserCounter([FromBody] symbol data)
 {
     try
     {
         using (APP_DBEntities db = new APP_DBEntities())
         {
             db.symbols.Add(data);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #4
0
 public bool DeleteUser([FromUri] string email)
 {
     try
     {
         using (APP_DBEntities db = new APP_DBEntities())
         {
             var user = db.users
                        .Where(b => b.email.Equals(email))
                        .FirstOrDefault();
             db.users.Remove(user);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }