/// <summary> /// Adds the request. /// </summary> /// <param name="key">The key.</param> public static void AddRequest(string key) { using (var db = new GenderEnt()) { var getKey = (from a in db.keys where a.key == key select a).SingleOrDefault(); if (getKey != null) { getKey.requests = getKey.requests + 1; db.SaveChanges(); } } }
/// <summary> /// Creates the request. /// </summary> /// <param name="key">The key.</param> /// <param name="name">The name.</param> /// <param name="ip">The ip.</param> public static void CreateRequest(string key, string name, string ip) { using (var db = new GenderEnt()) { db.requests.Add(new requests { created = DateTime.Now, ip = ip, key = key, name = name }); db.SaveChanges(); } }
/// <summary> /// Creates the key. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="requests"></param> public static int CreateKey(int userId, int requests) { using (var db = new GenderEnt()) { var newKey = new keys { user_id = userId, key = Guid.NewGuid().ToString(), requests = 0, requests_allowed = requests }; db.keys.Add(newKey); db.SaveChanges(); return(newKey.id); } }
/// <summary> /// Creates the user. /// </summary> /// <param name="data">The data.</param> /// <returns></returns> public static bool CreateUser(CreateUserModel data) { using (var db = new GenderEnt()) { if (!(from a in db.users.AsNoTracking() where a.email == data.Email select a.id).Any()) { db.users.Add(new users { company = data.Company, created = DateTime.Now, email = data.Email, firstname = data.Firstname, lastname = data.Lastname, password = BCrypt.HashPassword(data.Password, BCrypt.GenerateSalt()) }); db.SaveChanges(); return(true); } return(false); } }