public bool InsertRecord_UserProfile(tblUserProfile rec) { try { MentorJEntities context = new MentorJEntities(); tblUserProfile existingRec = ReadRecord_UserProfile(rec.UserID); if (existingRec == null) { //generate profile URL; //if (isUserNameTaken(rec) == true) //if check fails, then username already taken. //{ // return false; //} //if (isEmailTaken(rec) == true) //if check fails, then username already taken. //{ // return false; //} rec.Modified = DateTime.Now; context.tblUserProfiles.Add(rec); context.SaveChangesAsync(); return(true); } return(false); } catch (Exception ex) { throw ex; } }
public static string insertUpdateData(tblUserProfile data, string path) { try { var db = new SQLiteAsyncConnection(path); if (db.InsertAsync(data).ToString() == 0.ToString()) { db.UpdateAsync(data); } return("Single data file inserted or updated"); } catch (SQLiteException ex) { return(ex.Message); } }
public static bool deleteRecord(tblUserProfile data, string path) { try { var db = new SQLiteAsyncConnection(path); long userid = data.UserID; var query = db.GetAsync <tblUserProfile>(t => t.UserID == userid).Result; if (query != null) { return(db.DeleteAsync(query).IsCompleted); } return(false); } catch (SQLiteException ex) { throw ex; } }
public bool DeleteRecord_UserProfile(long ID) { try { MentorJEntities context = new MentorJEntities(); tblUserProfile existingRec = ReadRecord_UserProfile(ID); if (existingRec != null) //there is a record { context.tblUserProfiles.Remove(existingRec); context.SaveChangesAsync(); return(true); } return(false); } catch (Exception ex) { throw ex; } }
public bool UpdateRecord_UserProfile(tblUserProfile rec) { try { MentorJEntities context = new MentorJEntities(); tblUserProfile existingRec = ReadRecord_UserProfile(rec.UserID); if (existingRec != null) { rec.Modified = DateTime.Now; Serializer.Clone <tblUserProfile>(rec, existingRec); context.SaveChangesAsync(); return(true); } return(false); } catch (Exception ex) { throw ex; } }
public bool AddUpdateRecord_UserProfile(tblUserProfile rec) { try { MentorJEntities context = new MentorJEntities(); tblUserProfile existingRec = ReadRecord_UserProfile(rec.UserID); if (existingRec == null) //new record { return(InsertRecord_UserProfile(rec)); } else //found existing, update { return(UpdateRecord_UserProfile(rec)); } } catch (Exception ex) { throw ex; } }
public static tblUserProfile getRecord(tblUserProfile data, string path) { try { var db = new SQLiteAsyncConnection(path); long userid = data.UserID; // for a non-parameterless query var query = db.GetAsync <tblUserProfile>(t => t.UserID == userid).Result; //var query = table.Where(x => (x.UserID == userid)); //Linq Query if (query != null) { return(query); } return(null); } catch (SQLiteException ex) { throw ex; } //Get�specific�student�� }