public static string delete_data(string username, string email) { try { SiteUser su = new SiteUser(); MyProjectDataContext dbContext = new MyProjectDataContext(); var q = from a in dbContext.SiteUsers where a.Username == username && a.Email == email select a; if (q.Any()) { foreach (var a in q) { a.IsDeleted = true; return("deleted"); } } else { return("data not found"); } } catch { return("could not deleted."); } return(""); }
public bool ActivateAccount(Guid key) { MyProjectDataContext dbContext = new MyProjectDataContext(); ActivateUser act = new ActivateUser(); var q = from a in dbContext.ActivateUsers where a.ActivationKey == key select a; foreach (var a in q) { a.IsActivated = true; // a.IsExpired = true; try { dbContext.ActivateUsers.InsertOnSubmit(act); dbContext.SubmitChanges(); return(true); } catch { return(false); } } return(false); }
public bool AddAdmin(Guid userid, string username) { dbContext = new MyProjectDataContext(); string imgPath = "~/admin/dist/img/male-user.png"; AdminProfile ap = new AdminProfile(); ap.UserId = userid; ap.Username = username; ap.Created = DateTime.Now; ap.Updated = DateTime.Now; ap.UpdatedBy = username; ap.UserImgPath = imgPath; ap.Rejected = false; try { dbContext.AdminProfiles.InsertOnSubmit(ap); dbContext.SubmitChanges(); return(true); } catch (Exception ex) { throw ex; } return(false); }
public bool SaveSiteUsers(string username, string firstname, string lastname, string email, string address, string city, string state, string country, string createdby, Guid creatorid, string password) { dbContext = new MyProjectDataContext(); SiteUser su = new SiteUser(); su.Address = address; su.City = city; su.Country = country; su.CreatedBy = createdby; su.CreatedOn = DateTime.Now; su.CreatorId = creatorid; su.Email = email; su.FirstName = firstname; su.IsDeleted = false; su.IsRejected = false; su.Lastname = lastname; su.Password = password; su.State = state; su.UpdatedOn = DateTime.Now; su.Username = username; try { dbContext.SiteUsers.InsertOnSubmit(su); dbContext.SubmitChanges(); return(true); } catch { return(false); } return(false); }
public bool UpdateAdmin(Guid userid, string img_path, string username, string firstname, string lastname, string address, string city, string state, string country) { dbContext = new MyProjectDataContext(); var q = from a in dbContext.AdminProfiles where a.UserId == userid select a; if (q.Any()) { AdminProfile ap = new AdminProfile(); ap.Address = address; ap.City = city; ap.Country = country; ap.FirstName = firstname; ap.LastName = lastname; ap.State = state; ap.Updated = DateTime.Now; ap.UpdatedBy = username; ap.UserId = userid; ap.UserImgPath = img_path; ap.Username = username; try { dbContext.AdminProfiles.InsertOnSubmit(ap); dbContext.SubmitChanges(); return(true); } catch { return(false); } } return(false); }
public static string show(Guid userid, string username, string websitename) { //string msg = ""; int websiteid = GetWebsiteId(userid, username, websitename); string msg = ""; MyProjectDataContext da = new MyProjectDataContext(); var q = from a in da.WebsitePages where a.Username == username && a.UserId == userid && a.WebsiteId == websiteid select a; if (q.Any()) { msg = "data"; } else { msg = "nothing"; } //foreach (var o in q) //{ // if (o.PageName.Count() == 0) // { // msg = "nothing"; // //pnl_web.Visible = true; // } // else // { // msg = "data"; // //pnl_web.Visible = false; // } //} return(msg); }
public IEnumerable <aspnet_User> GetUsers() { dbContext = new MyProjectDataContext(); var q = from a in dbContext.aspnet_Users select a; return(q); }
public IEnumerable <SiteUser> GetAllSiteUsers() { dbContext = new MyProjectDataContext(); var q = from a in dbContext.SiteUsers select a; return(q); }
public IEnumerable <ActivateUser> ActivationInfo(Guid key) { MyProjectDataContext dbcontex = new MyProjectDataContext(); var q = from a in dbcontex.ActivateUsers where a.ActivationKey == key select a; return(q); }
public IEnumerable <ActivateUser> ValidateKey(Guid key) { MyProjectDataContext dbContext = new MyProjectDataContext(); var q = from a in dbContext.ActivateUsers where a.ActivationKey == key select a; return(q); }
public IEnumerable <SiteUser> Get_Site_Users(string username, Guid creatorid) { dbContext = new MyProjectDataContext(); var q = from a in dbContext.SiteUsers where a.Username == username && a.CreatorId == creatorid select a; return(q); }
public IEnumerable <SubPage> GetPages() { dbContext = new MyProjectDataContext(); var q = from a in dbContext.SubPages select a; // dbContext.Connection.Close(); return(q); }
public IEnumerable <AdminProfile> GetUserImage(Guid userid) { dbContext = new MyProjectDataContext(); var q = from a in dbContext.AdminProfiles where a.UserId == userid select a; return(q); }
public IEnumerable <BodyContent> GetWebsites() { dbContext = new MyProjectDataContext(); var q = from a in dbContext.BodyContents select a; // dbContext.Connection.Close(); return(q); }
public static string get_page(string username, string websitename) { string msg = ""; MyProjectDataContext da = new MyProjectDataContext(); var q = from a in da.SubPages where a.UserName == username && a.WebsiteName == websitename select a; return(msg); }
public void DoExpire(Guid key) { MyProjectDataContext dbcontex = new MyProjectDataContext(); var q = from a in dbcontex.ActivateUsers where a.ActivationKey == key select a; foreach (var a in q) { a.IsExpired = true; } }
public static int GetWebsiteId(Guid userid, string username, string websitename) { MyProjectDataContext da = new MyProjectDataContext(); int id = 0; var q = from a in da.Websites where a.UserId == userid && a.Username == username && a.WebsiteName == websitename select a.WebsiteId; if (q.Any()) { id = Convert.ToInt32(q.Single()); } return(id); }
public static WebsiteName[] getwebsites(string username) { List <WebsiteName> websitename = new List <WebsiteName>(); MyProjectDataContext dbcontext = new MyProjectDataContext(); var q = from a in dbcontext.Websites where a.Username == username select a; foreach (var a in q) { WebsiteName wname = new WebsiteName(); wname.Name = a.WebsiteName; websitename.Add(wname); } return(websitename.ToArray()); }
public bool IsActivated(Guid userid) { MyProjectDataContext dbContext = new MyProjectDataContext(); var q = from a in dbContext.ActivateUsers where a.UserId == userid select a; foreach (var a in q) { if (a.IsActivated == true && a.IsExpired == false) { return(true); } else { return(false); } } return(false); }
public static PageData[] getpage(string username, string websitename, Guid userid) { //getting website id from tables int websiteid = GetWebsiteId(userid, username, websitename); List <PageData> page = new List <PageData>(); MyProjectDataContext da = new MyProjectDataContext(); var q = from a in da.WebsitePages where a.Username == username && a.WebsiteId == websiteid select a; foreach (var o in q) { PageData pd = new PageData(); pd.PageName = o.PageName; pd.WebsiteName = websitename; page.Add(pd); } return(page.ToArray()); }
public bool SaveActivationKey(Guid userid, Guid key) { MyProjectDataContext dbContext = new MyProjectDataContext(); ActivateUser act = new ActivateUser(); act.ActivationKey = key; act.Created = DateTime.Now; act.IsActivated = false; act.IsExpired = false; act.UserId = userid; try { dbContext.ActivateUsers.InsertOnSubmit(act); dbContext.SubmitChanges(); return(true); } catch { return(false); } }
//[ScriptMethod(UseHttpGet = false)] public static string delete(Guid userid, string websitename, string username) { string msg; // Response.Write(userid); // Response.Write(websitename); msg = "Hello"; // datalayer dl = new datalayer(); MyProjectDataContext da = new MyProjectDataContext(); var q = from a in da.Websites where a.UserId == userid && a.WebsiteName == websitename select a; int websiteid = GetWebsiteId(userid, username, websitename); var q1 = from b in da.WebsitePages where b.WebsiteId == websiteid select b; foreach (var o in q1) { da.WebsitePages.DeleteOnSubmit(o); // removing foreign key references } foreach (var o in q) { da.Websites.DeleteOnSubmit(o); } try { da.SubmitChanges(); msg = "success"; } catch { msg = "error"; } // msg=dl.Delete_Website(userid, websitename); return(msg); }
public static void delete_database(int databaseid) { MyProjectDataContext dbcontext = new MyProjectDataContext(); DatabaseManagement dbManage = new DatabaseManagement(); string websitename = dbManage.GetWebsiteNameByDbId(databaseid); if (dbManage.DeleteDatabaseById(databaseid)) { System.Web.UI.Page ob = new System.Web.UI.Page(); string db_path = "~/web-design/" + ob.Session[Constants.Session.USERNAME].ToString() + "/" + websitename + "/" + "App_Data/"; bool exists = System.IO.Directory.Exists(ob.Server.MapPath(db_path)); if (exists) { //System.IO.Directory.CreateDirectory(Server.MapPath(db_path)); System.IO.Directory.Delete(ob.Server.MapPath(db_path), true); } } else { } // var q= }
public RealDataRepository() { _dc = new MyProjectDataContext(); //or however you do it. }
//[ScriptMethod(UseHttpGet = false)] public static string delete(Guid userid, string websitename, string username) { string msg; // Response.Write(userid); // Response.Write(websitename); msg = "Hello"; // datalayer dl = new datalayer(); MyProjectDataContext da = new MyProjectDataContext(); var q = from a in da.Websites where a.UserId == userid && a.WebsiteName == websitename select a; int websiteid = GetWebsiteId(userid, username, websitename); var q1 = from b in da.WebsitePages where b.WebsiteId == websiteid select b; foreach (var o in q1) { da.WebsitePages.DeleteOnSubmit(o); // removing foreign key references } foreach (var o in q) { da.Websites.DeleteOnSubmit(o); } try { //deleting name from drop down web_design_CreateWebsite ob = new web_design_CreateWebsite(); ob.bind_website_ddl(); //ob.ddl_select_website.Items.Remove(websitename); //-------------------------- //deleting website folder and files string subPath = "~/web-design/" + username + "/" + websitename + "/"; System.Web.UI.Page p = new System.Web.UI.Page(); //creating instance of object bool exists = System.IO.Directory.Exists(p.Server.MapPath(subPath)); if (exists) { System.IO.Directory.Delete(p.Server.MapPath(subPath), true); } //deleting db DatabaseManagement dbManage = new DatabaseManagement(); dbManage.DeleteDatabaseByWebsiteName(userid, websitename, username); // end------------- da.SubmitChanges(); msg = "success"; } catch { msg = "error"; } // msg=dl.Delete_Website(userid, websitename); return(msg); }