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); } }
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 user[] GetTeacherUsers([FromUri] string garden) { try { using (APP_DBEntities db = new APP_DBEntities()) { var users = db.users .Where(b => b.gardenname.Equals(garden) && b.type.ToLower().Equals("child")); user[] res = users.ToArray(); return(res); } } catch (Exception) { return(null); } }
public userContacts GetChildContacts([FromUri] string email) { try { using (APP_DBEntities db = new APP_DBEntities()) { var userContacts = db.contacts .Where(b => b.email.Equals(email)) .FirstOrDefault(); return(userContacts); } } catch (Exception ex) { return(null); } }
public user GetUser([FromUri] string email) { try { using (APP_DBEntities db = new APP_DBEntities()) { var user = db.users .Where(b => b.email.Equals(email)) .FirstOrDefault(); return(user); } } catch (Exception ex) { return(null); } }
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); } }
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); } }
public symbol[] GetUserAllSymbolsUsage([FromUri] string email) { try { using (APP_DBEntities db = new APP_DBEntities()) { var userSymbol = db.symbols.Where(u => u.email.Equals(email)); if (userSymbol != null) { return(userSymbol.ToArray()); } return(null); } } catch (Exception ex) { return(null); } }
public string GetParentContact([FromUri] string Parentemail, [FromUri] bool isParent) { if (!isParent) { return("This is not a parent"); } try { using (APP_DBEntities db = new APP_DBEntities()) { var userContacts = db.contacts .Where(b => b.father.Equals(Parentemail) || b.mother.Equals(Parentemail)) .FirstOrDefault(); return(userContacts.email); } } catch (Exception ex) { return(null); } }
public user GetTeacher([FromUri] string email, [FromUri] string type) { try { using (APP_DBEntities db = new APP_DBEntities()) { var user = db.users .Where(b => b.email.Equals(email)) .FirstOrDefault(); var garden = user.gardenname; var teacher = db.users .Where(b => b.type.ToLower().Equals("teacher") && b.gardenname.Equals(garden)) .FirstOrDefault(); return(teacher); } } catch (Exception) { return(null); } }