public void Load() { PrivacyList privacys = new PrivacyList(); privacys.Load(); Assert.IsTrue(privacys.Count > 0); }
private static Privacy LoadPrivacy() { PrivacyList privacies = new PrivacyList(); privacies.Load(); Privacy privacy = privacies.FirstOrDefault(p => p.Description == "Public"); return(privacy); }
public void Delete() { PrivacyList privacys = new PrivacyList(); privacys.Load(); Privacy privacy = privacys.FirstOrDefault(p => p.Description == "TestUpdate"); int rowsAffected = privacy.Delete(); Assert.IsTrue(rowsAffected == 1); }
public void LoadById() { PrivacyList privacys = new PrivacyList(); privacys.Load(); Privacy privacy = new Privacy(); privacy.LoadById(privacys.FirstOrDefault(p => p.Description == "Test").Id); Assert.AreEqual("Test", privacy.Description); }
// GET: Privacy public ActionResult Index() { User userin = System.Web.HttpContext.Current.Session["user"] as User; if (userin == null || userin.UserTypeDescription != "Admin") { return(RedirectToAction("Index", "Home")); } privacies = new PrivacyList(); privacies.Load(); return(View(privacies)); }
public ActionResult Create(ProjectPrivaciesUserStatuses ppus, string returnurl) { //double check authentication if (Authenticate.IsAuthenticated()) { try { PrivacyList plist = new PrivacyList(); plist.Load(); ppus.Privacies = plist; StatusList slist = new StatusList(); slist.Load(); ppus.Statuses = slist; if (ppus.SelectedLanguages == null) { ppus.SelectedLanguages = new List <string>(); } ProjectList Projects = new ProjectList(); User userin = System.Web.HttpContext.Current.Session["user"] as User; string username = userin.Username; string strUserID = userin.Id.ToString(); ppus.Project.UserId = userin.Id; ppus.Project.UserEmail = userin.Email; Projects.LoadbyUser(userin); if (ppus.Project.Name == null) { ModelState.AddModelError(string.Empty, "Project requires a name!"); } else { foreach (Project p in Projects) { if (ppus.Project.Name == p.Name) { ModelState.AddModelError(string.Empty, "Project name already exists!"); } } if (ppus.DateCreated == null) { ModelState.AddModelError(string.Empty, "Date Created required!"); } else if (ppus.LastUpdated == null) { ppus.LastUpdated = ppus.DateCreated; } } UploadedImage ui = new UploadedImage { FilePath = ppus.Project.Image, Fileupload = ppus.Fileupload, UserName = username, ObjectType = "Project", ObjectName = ppus.Project.Name }; UploadedZip uz = new UploadedZip { FilePath = ppus.Project.Filepath, Fileupload = ppus.Fileupload, UserName = username, ProjectName = ppus.Project.Name }; if (!ModelState.IsValid) { ppus.User = new User(); ppus.SelectedLanguages = new List <string>(); ppus.AvailableLanguages = new List <SelectListItem>(); ppus.Languages = new LanguageList(); ppus.Language = new Language(); ppus.ProjectLanguage = new ProjectLanguage(); ppus.ProjectLanguages = new ProjectLanguageList(); ppus.User.LoadById(userin.Id); ppus.Languages.Load(); ppus.AvailableLanguages = GetLanguages(ppus.Languages); return(View(ppus)); } string fp = ui.Upload(); // fp will return null if no upload file was choosen else use upload file to save to database if (fp != null) { ppus.Project.Image = fp; } else { ppus.Project.Image = null; } fp = uz.Upload(); // fp will return null if no upload file was choosen else use upload file to save to database if (fp != null) { ppus.Project.Filepath = fp; } else { ppus.Project.Filepath = null; } ppus.Project.Insert(ppus.SelectedLanguages); return(RedirectToAction("EditProjects", "UserProfile", new { returnurl = HttpContext.Request.Url })); } catch { return(View(ppus)); } } else { return(RedirectToAction("Index", "Login", new { returnurl = HttpContext.Request.Url })); } }
public ActionResult EditProject(Guid id, ScreenshotProjects ppus) { if (Authenticate.IsAuthenticated()) { try { ppus.Language = new Language(); ppus.Languages = new LanguageList(); if (ppus.SelectedLanguages == null) { ppus.SelectedLanguages = new List <string>(); } if (ppus.AvailableLanguages == null) { ppus.AvailableLanguages = new List <SelectListItem>(); if (ppus.Languages.Count < 1) { //Load Languages ppus.Languages.Load(); } else { // Languages already loaded } ppus.AvailableLanguages = GetLanguages(ppus.Languages); } PrivacyList plist = new PrivacyList(); plist.Load(); ppus.Privacies = plist; StatusList slist = new StatusList(); slist.Load(); ppus.ProjectLanguage = new ProjectLanguage(); ppus.ProjectLanguages = new ProjectLanguageList(); ppus.Statuses = slist; ppus.ScreenshotList = new ScreenshotList(); ppus.ScreenshotList.LoadbyProjectID(id); ppus.ProjectId = id; // Deletes all languages associated with project currently ppus.ProjectLanguages.LoadByProjectId(id); foreach (ProjectLanguage pl in ppus.ProjectLanguages) { pl.Delete(); } // Insert New languages parsed from input into ProjectLanguage table foreach (var pl in ppus.SelectedLanguages) { ProjectLanguage projlang = new ProjectLanguage(); ppus.ProjectLanguage.ProjectId = id; ppus.ProjectLanguage.LanguageId = (Guid.Parse(pl)); ppus.ProjectLanguage.Insert(); } User userin = System.Web.HttpContext.Current.Session["user"] as User; ProjectList Projects = new ProjectList(); Projects.LoadbyUser(userin); string username = userin.Username; string strUserID = userin.Id.ToString(); if (ppus.Project.Name == null) { ModelState.AddModelError(string.Empty, "Project requires a name!"); } else { foreach (Project p in Projects) { if (ppus.Project.Name == p.Name) { if (ppus.Project.Id != p.Id) { ModelState.AddModelError(string.Empty, "Another project already exists with this name!"); } } } if (ppus.DateCreated == null) { ModelState.AddModelError(string.Empty, "Date Created required!"); } else if (ppus.LastUpdated == null) { ppus.LastUpdated = ppus.DateCreated; } } UploadedZip zu = new UploadedZip { FilePath = ppus.Project.Filepath, Fileupload = ppus.ZipFileupload, UserName = username, ProjectName = ppus.Project.Name }; UploadedImage ui = new UploadedImage { FilePath = ppus.Project.Image, Fileupload = ppus.Fileupload, UserName = username, ObjectType = "Project", ObjectName = ppus.Project.Name }; if (!ModelState.IsValid) { ppus.Languages = new LanguageList(); ppus.SelectedLanguages = new List <string>(); ppus.AvailableLanguages = new List <SelectListItem>(); ppus.Privacies = new PrivacyList(); ppus.Statuses = new StatusList(); ppus.User = new User(); ppus.User.LoadById(userin.Id); ppus.Privacies.Load(); ppus.Statuses.Load(); ppus.Languages.Load(); ppus.AvailableLanguages = GetLanguages(ppus.Languages); return(View(ppus)); } string fp = ui.Upload(); string zp = zu.Upload(); // fp will return null if no upload file was choosen else use upload file to save to database if (fp != null) { ppus.Project.Image = fp; } else { ppus.Project.Image = null; } if (zp != null) { ppus.Project.Filepath = zp; } else { ppus.Project.Filepath = null; } ppus.Project.DateCreated = ppus.DateCreated; ppus.Project.LastUpdated = ppus.LastUpdated; ppus.Project.Update(); return(RedirectToAction("EditProjects", "UserProfile")); } catch { return(View(ppus)); } } else { return(RedirectToAction("Index", "Login", new { returnurl = HttpContext.Request.Url })); } }
public ActionResult EditPortfolio(Guid id, UserProfile up) { if (Authenticate.IsAuthenticated()) { try { User userin = System.Web.HttpContext.Current.Session["user"] as User; PortfolioList Portfolios = new PortfolioList(); Portfolios.LoadbyUser(userin); up.Portfolios = Portfolios; ProjectList projects = new ProjectList(); projects.LoadbyPortfolioID(id); PrivacyList privacies = new PrivacyList(); privacies.Load(); up.Privacies = privacies; up.Projects = projects; string username = userin.Username; if (up.Portfolio.Name == null) { ModelState.AddModelError(string.Empty, "Portfolio requires a name!"); } else { foreach (Portfolio p in Portfolios) { if (up.Portfolio.Name == p.Name) { if (up.Portfolio.Id != p.Id) { ModelState.AddModelError(string.Empty, "Another portfolio already exists with this name!"); } } } } UploadedImage ui = new UploadedImage { FilePath = up.Portfolio.PortfolioImage, Fileupload = up.Fileupload, UserName = username, ObjectType = "Portfolio", ObjectName = up.Portfolio.Name }; string fp = ui.Upload(); // fp will return null if no upload file was choosen else use upload file to save to database if (fp != null) { up.Portfolio.PortfolioImage = fp; } else { up.Portfolio.PortfolioImage = null; } if (!ModelState.IsValid) { up.Privacies = new PrivacyList(); up.User = new User(); up.User.LoadById(userin.Id); up.Privacies.Load(); up.Projects.LoadbyPortfolioID(up.Portfolio.Id); return(View(up)); } up.Portfolio.Update(); return(RedirectToAction("EditPortfolios")); } catch { return(View(up)); } } else { return(RedirectToAction("Index", "Login", new { returnurl = HttpContext.Request.Url })); } }