public void ResetPassword(string email, string newPass) { SQLConnectionDataContext db = new SQLConnectionDataContext(); User usr; usr = db.Users.Select(e => e).Where(user => user.Email == email).First(); usr.Password = newPass.ToString(); db.SubmitChanges(); }
public void DeleteVideo(string videoname, string username) { SQLConnectionDataContext db = new SQLConnectionDataContext(); var query = from p in db.Videos where p.VideoName.Contains(videoname) && p.Username.Contains(username) select p; db.Videos.DeleteAllOnSubmit(query); db.SubmitChanges(); }
public void DeleteMsg(int msgID) { SQLConnectionDataContext db = new SQLConnectionDataContext(); var query = from p in db.Messages where p.MsgID == msgID select p; db.Messages.DeleteAllOnSubmit(query); db.SubmitChanges(); }
public void UpdateVideo(string videoname, string username, string category, string sharedTo) { SQLConnectionDataContext db = new SQLConnectionDataContext(); Video row; row = (db.Videos.Select(e => e).Where(p => p.VideoName == videoname && p.Username == username)).First(); row.VideoName = videoname; row.Category = category; row.SharedTo = sharedTo; db.SubmitChanges(); }
public bool Delete(string email) { SQLConnectionDataContext db = new SQLConnectionDataContext(); var query = from p in db.Users where p.Email.Contains(email) select p; db.Users.DeleteAllOnSubmit(query); db.SubmitChanges(); return(true); }
public bool UpdData(string email, string username, string password, string dob, string address, string phoneNumber) { SQLConnectionDataContext db = new SQLConnectionDataContext(); User row = db.Users.Single(p => p.Email == email); row.Username = username; row.Password = password; row.DateOfBirth = dob; row.Address = address; row.PhoneNumber = phoneNumber; db.SubmitChanges(); return(true); }
public string SelectMsg(int msgID) { SQLConnectionDataContext db = new SQLConnectionDataContext(); viewMessage row; row = db.viewMessages.Select(e => e).Where(e => e.MsgID == msgID).First(); Message r = db.Messages.Single(p => p.MsgID == msgID); r.IsRead = true; db.SubmitChanges(); return(row.SentFrom.ToString().Trim() + "," + row.Subject.ToString().Trim() + "," + row.MsgContent.ToString().Trim()); }
public UploadFile DoUpload(string videoname, string username, string filename, string category, string sharedTo, byte[] content, bool append) { SQLConnectionDataContext db = new SQLConnectionDataContext(); Video row = new Video() { VideoName = videoname, Username = username, FilePath = "/FileStore/" + username.Trim() + "/" + filename, Category = category, }; if (sharedTo[sharedTo.Length] != ',') { row.SharedTo = sharedTo + ','; } else { row.SharedTo = sharedTo; } db.Videos.InsertOnSubmit(row); try { db.SubmitChanges(); } catch { } string folder = Path.GetFullPath(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"FileStore\" + username.Trim() + @"\")); if (!System.IO.Directory.Exists(folder)) { System.IO.Directory.CreateDirectory(folder); } FileMode m = FileMode.Create; if (append) { m = FileMode.Append; } using (FileStream fs = new FileStream(folder + @"\" + filename, m, FileAccess.Write)) { fs.Write(content, 0, content.Length); } UploadFile file = new UploadFile { Name = filename, FileStoreUrl = "../FileStore/" + filename }; return(file); }
public void SendMsg(string subject, string msgContent, string sentFrom, string sentTo, string SentDate) { SQLConnectionDataContext db = new SQLConnectionDataContext(); Message row = new Message() { MsgID = SelectLastMsgId(), Subject = subject, MsgContent = msgContent, SentFrom = sentFrom, SentTo = sentTo, SentDate = SentDate, IsDeleted = false, IsRead = false, }; db.Messages.InsertOnSubmit(row); try { db.SubmitChanges(); } catch { } }
public void InsertData(string user, string pass, string email, string dob, string address, string phoneNumber, int securityQuestionId, string answer) { SQLConnectionDataContext db = new SQLConnectionDataContext(); User row = new User() { Username = user, Password = pass, Email = email, DateOfBirth = dob, Address = address, PhoneNumber = phoneNumber, SecurityQuestionId = securityQuestionId, Answer = answer, IsAdmin = false, IsBanned = false, }; db.Users.InsertOnSubmit(row); try { db.SubmitChanges(); } catch { } }