public bool changeUserName(User u, string nUName) { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); var query = from user in NIData.Users where (user.UserID == u.UserID) select user; // now create business objects from the Station entities, and build a list // to return: foreach (var user in query) { user.UserName = nUName; } try { NIData.SubmitChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool changeAddr(Listing l, string newAddr) { newAddr = newAddr.Replace("'", "''"); DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); var query = from listing in NIData.Listings where (listing.ListingID == l.ListingID) select listing; foreach (var listing in query) { listing.StAddr = newAddr; } try { NIData.SubmitChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool postListing(User u, string stAddr, int zipCode, int sqFeet, float noBath, int noBed, string type, decimal price, string picture) { DataTier.Listing newListing = new DataTier.Listing(); newListing.UserID = u.UserID; newListing.StAddr = stAddr.Replace("'", "''"); newListing.ZipCode = zipCode; newListing.SqFeet = sqFeet; newListing.NoBath = noBath; newListing.NoBed = noBed; newListing.Type = type; newListing.Price = price; newListing.Picture = picture; try { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); NIData.Listings.InsertOnSubmit(newListing); NIData.SubmitChanges(); } catch (Exception ex) { return(false); } return(true); }
public bool sendMessage(string message, User sender, int reciever, int threadid) { DataTier.Message newMessage = new DataTier.Message(); newMessage.SenderID = sender.UserID; newMessage.ReceiverID = reciever; newMessage.MessageBody = message; newMessage.ThreadID = threadid; try { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); NIData.Messages.InsertOnSubmit(newMessage); NIData.SubmitChanges(); } catch (Exception ex) { return(false); } return(true); }
public bool changePrice(Listing l, decimal newprice) { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); var query = from listing in NIData.Listings where (listing.ListingID == l.ListingID) select listing; foreach (var listing in query) { listing.Price = newprice; } try { NIData.SubmitChanges(); return(true); } catch (Exception ex) { return(false); } }
public bool changeBeds(Listing l, int newbeds) { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); var query = from listing in NIData.Listings where (listing.ListingID == l.ListingID) select listing; foreach (var listing in query) { listing.NoBed = newbeds; } try { NIData.SubmitChanges(); return(true); } catch (Exception ex) { return(false); } }
/** * Create a new user account in database, return true on success, false on failure **/ public bool createAccount(string uName, string pass, string fName, string lName, string email, string phone, byte seller) { DataTier.User newUser = new DataTier.User(); newUser.UserName = uName.Replace("'", "''"); newUser.Password = pass.Replace("'", "''"); newUser.FirstName = fName.Replace("'", "''"); newUser.LastName = lName.Replace("'", "''"); newUser.Email = email.Replace("'", "''"); newUser.MobileNo = phone.Replace("'", "''"); newUser.Seller = seller; try { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); NIData.Users.InsertOnSubmit(newUser); NIData.SubmitChanges(); } catch (Exception ex) { return(false); } return(true); }
public bool deleteMessage(int mid) { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); var deleteMessages = from message in NIData.Messages where message.MessageID == mid select message; foreach (var message in deleteMessages) { NIData.Messages.DeleteOnSubmit(message); } try { NIData.SubmitChanges(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); // Provide for exceptions. } }
public bool removeListing(string addr) { DataTier.UsersDBDataContext NIData = new DataTier.UsersDBDataContext(); var deleteOrderDetails = from listing in NIData.Listings where listing.StAddr.Equals(addr) select listing; foreach (var detail in deleteOrderDetails) { NIData.Listings.DeleteOnSubmit(detail); } try { NIData.SubmitChanges(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); // Provide for exceptions. } }