public ActionResult EditAdvertise(Item item) { using (var db = new ProjectDatabaseContext()) { try { if (ModelState.IsValid) { db.Items.Attach(item); db.ObjectStateManager.ChangeObjectState(item, EntityState.Modified); db.SaveChanges(); var username = Convert.ToString(Session["username"]); if (Convert.ToString(Session["status"]).Equals("Admin")) { return RedirectToAction("Index", "ItemList"); } return RedirectToAction("Index", "ItemList", new {id = username}); } var id = Convert.ToInt32(Session["tempid"]); var q = (from p in db.Items where p.ItemID == id select p).FirstOrDefault(); return View(q); } catch (Exception e) { var id = Convert.ToInt32(Session["tempid"]); var q = (from p in db.Items where p.ItemID == id select p).FirstOrDefault(); return View(q); } } }
public ActionResult EditProfile(Contact con) { using (var db = new ProjectDatabaseContext()) { try { if (ModelState.IsValid) { db.Contacts.Attach(con); db.ObjectStateManager.ChangeObjectState(con, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } var username = Session["username"].ToString(); var q = (from p in db.Contacts where p.Username == username select p).FirstOrDefault(); return View(q); } catch (Exception e) { return View(); } } }
// // GET: /EditAd/ public ActionResult Index(int id) { using (var db = new ProjectDatabaseContext()) { var query = (from p in db.Items where p.ItemID == id select p.SellerUsername).FirstOrDefault(); if (Convert.ToString(Session["username"]).Equals(query) || Convert.ToString(Session["status"]).Equals("Admin")) { var item = db.Items.Single(e => e.ItemID == id); db.Items.DeleteObject(item); var deleteItemImages = from p in db.ItemImages where p.ItemID == id select p; foreach (var detail in deleteItemImages) { db.ItemImages.DeleteObject(detail); } db.SaveChanges(); var username = Convert.ToString(Session["username"]); if (Convert.ToString(Session["status"]).Equals("Admin")) { return RedirectToAction("Index", "ItemList"); } return RedirectToAction("Index", "ItemList", new {id = username}); } return RedirectToAction("Index", "Home"); } }
public ActionResult ItemImage(int id = 0) { using (var db = new ProjectDatabaseContext()) { var q = (from p in db.ItemImages where p.ItemID == id select p).ToList(); return View(q); } }
// // GET: /Comment/ public ActionResult Index(int id) { Session["tempid"] = id; using (var db = new ProjectDatabaseContext()) { var q = from p in db.Comments where p.ItemID == id select p; return View(q.ToList()); } }
public ActionResult DeleteComment(int id) { using (var db = new ProjectDatabaseContext()) { var itemid = Convert.ToString(Session["tempid"]); var q = (from p in db.Comments where p.CommentID == id select p).FirstOrDefault(); db.Comments.DeleteObject(q); db.SaveChanges(); return RedirectToAction("Index", new {id = itemid}); } }
public FileContentResult GetImage(string id) { var db = new ProjectDatabaseContext(); var q = from p in db.Contacts where p.Username == id select p; var byteArray = q.FirstOrDefault().ImageBytes; if (byteArray != null) { return new FileContentResult(byteArray, q.FirstOrDefault().ImageContentType); } return null; }
// // GET: /Feedback/ public ActionResult Index(int? page) { if (Convert.ToString(Session["status"]).Equals("Admin")) { var db = new ProjectDatabaseContext(); var q = from p in db.Feedbacks orderby p.Time descending select p; return View(q.ToList().ToPagedList(page ?? 1, 8)); } return RedirectToAction("Index", "Home"); }
// // GET: /ItemProfile/ public ActionResult Index(int id = 0) { if (id != 0) { using (var db = new ProjectDatabaseContext()) { var q = (from p in db.Items where p.ItemID == id select p).FirstOrDefault(); return View(q); } } return RedirectToAction("Index", "ItemList"); }
public ActionResult EditProfile() { using (var db = new ProjectDatabaseContext()) { if (Session["username"] != null) { var username = Session["username"].ToString(); var q = (from p in db.Contacts where p.Username == username select p).FirstOrDefault(); return View(q); } return RedirectToAction("Index", "Home"); } }
public ActionResult Delete(int id) { if (Convert.ToString(Session["status"]).Equals("Admin")) { using (var db = new ProjectDatabaseContext()) { var fb = db.Feedbacks.SingleOrDefault(e => e.Id == id); db.Feedbacks.DeleteObject(fb); db.SaveChanges(); return RedirectToAction("Index", "Feedback"); } } return RedirectToAction("Index", "Home"); }
public ActionResult Index(int itemid, string comment) { using (var db = new ProjectDatabaseContext()) { var com = new Comment(); com.ItemID = itemid; com.Username = Convert.ToString(Session["username"]); com.CommentMessage = comment; com.Time = DateTime.Now; db.Comments.AddObject(com); db.SaveChanges(); return RedirectToAction("Index", "ItemProfile", new {id = itemid}); } }
public FileContentResult GetItemImage(int id) { var db = new ProjectDatabaseContext(); var q = from p in db.ItemImages where p.ItemID == id select p; var byteArray = q.FirstOrDefault().ImageBytes; if (byteArray != null) { return new FileContentResult(byteArray, q.FirstOrDefault().ContentType); } return null; }
public ActionResult ImageUpload(FileUploadViewModel FileModel, string submit) { if (submit.Equals("Skip")) { return RedirectToAction("Success", "PostAd"); } using (var db = new ProjectDatabaseContext()) { var service = new FileUploadService(); foreach (var item in FileModel.file) { service.SaveFileDetails(item, Convert.ToInt32(Session["tempitemid"].ToString())); } return RedirectToAction("Success", "PostAd"); } }
public void SaveFileDetails(HttpPostedFileBase file, int id) { var newFile = new ItemImage(); newFile.ContentType = file.ContentType; newFile.ItemID = id; newFile.ImageBytes = ConvertToBytes(file); if (file.ContentLength < (1024*1024) && (file.ContentType.Contains("/jpg") || file.ContentType.Contains("/jpeg") || file.ContentType.Contains("/png") || file.ContentType.Contains("/bmp"))) { using (var db = new ProjectDatabaseContext()) { db.ItemImages.AddObject(newFile); db.SaveChanges(); } } }
public ActionResult EditAdvertise(int id) { using (var db = new ProjectDatabaseContext()) { var query = (from p in db.Items where p.ItemID == id select p.SellerUsername).FirstOrDefault(); if (Convert.ToString(Session["username"]).Equals(query) || Convert.ToString(Session["status"]).Equals("Admin")) { Session["tempid"] = id; var q = (from p in db.Items where p.ItemID == id select p).FirstOrDefault(); return View(q); } return RedirectToAction("Index", "Home"); } }
public ActionResult PersonalInfo(Contact contact, HttpPostedFileBase FileUpload) { if (ModelState.IsValid) { try { contact.Username = Session["tempuser"].ToString(); using (var db = new ProjectDatabaseContext()) { if (FileUpload != null) { if (FileUpload.ContentLength < (1024*1024) && (FileUpload.ContentType.Contains("/jpg") || FileUpload.ContentType.Contains("/jpeg") || FileUpload.ContentType.Contains("/png") || FileUpload.ContentType.Contains("/bmp"))) { contact.ImageContentType = FileUpload.ContentType; contact.ImageBytes = ConverToByte(FileUpload); ViewBag.Msg = null; } else { ViewBag.Msg = "<span align='center'>Invalid File</span><br /><br />"; } } if (ViewBag.Msg == null) { db.Contacts.AddObject(contact); db.SaveChanges(); return RedirectToAction("Success", "Registration"); } return View(); } } catch (Exception e) { return View(); } } return View(); }
public ActionResult Index(FormCollection Col) { using (var context = new ProjectDatabaseContext()) { var username = Col["UsernameTB"]; var password = Col["PasswordTB"]; var query = from p in context.LoginInfos where p.Username.Equals(username) && p.Password.Equals(password) select p; var count = query.Count(); if (count == 1) { Session["username"] = query.FirstOrDefault().Username; Session["password"] = query.FirstOrDefault().Password; Session["status"] = query.FirstOrDefault().Status; return RedirectToAction("Index", "Home"); } ViewBag.msg = "Incorrect Username/Password"; return View(); } }
public ActionResult Index(LoginInfo log, string confirm) { if (ModelState.IsValid) { try { if (confirm != null && log.Password.Equals(confirm)) { using (var db = new ProjectDatabaseContext()) { var count = (from p in db.LoginInfos where p.Username == log.Username select p).Count(); if (count == 0) { Session["tempuser"] = log.Username; log.Status = "Member"; db.LoginInfos.AddObject(log); db.SaveChanges(); } else { ViewBag.Msg = "<span align='center'>Username Taken</span><br /><br />"; return View(); } } return RedirectToAction("PersonalInfo", "Registration"); } ViewBag.Msg = "<span align='center'>Password Didn't Match</span><br /><br />"; return View(); } catch (Exception e) { return View(); } } return View(); }
public ActionResult Index(FormCollection col) { using (var db = new ProjectDatabaseContext()) { var subject = col["subjectTB"]; var message = col["messageTB"]; //DateTime time = DateTime.Now; var fb = new Feedback(); fb.Subject = subject; fb.Message = message; if (Session["username"] == null) fb.Username = "******"; else fb.Username = Session["username"].ToString(); fb.Time = DateTime.Now; db.Feedbacks.AddObject(fb); db.SaveChanges(); return RedirectToAction("Success", "Contact"); } }
public ActionResult Index(Item item) { if (ModelState.IsValid) { using (var db = new ProjectDatabaseContext()) { try { item.SellerUsername = Session["username"].ToString(); item.Posted = DateTime.Now; item.Price = Convert.ToDouble(item.Price); db.Items.AddObject(item); db.SaveChanges(); Session["tempitemid"] = item.ItemID; return RedirectToAction("ImageUpload", "PostAd"); } catch (Exception) { return View(); } } } return View(); }
public RequestsController(ProjectDatabaseContext context) { _context = context; }
public SetupController() { _setupContext = new ProjectDatabaseContext(); }
public ItemDetailsController(ProjectDatabaseContext context) { _context = context; }
public AuthorsController(ProjectDatabaseContext context) { _context = context; }
public StockController() { _stockContext = new ProjectDatabaseContext(); }
public StudentsController(ProjectDatabaseContext context) { _context = context; }
public BookCopiesController(ProjectDatabaseContext context) { _context = context; }
public AdminController(ProjectDatabaseContext projectdatabasecontext) { _projectDatabaseContext = projectdatabasecontext; }
public MainController(ILogger <HomeController> logger, ProjectDatabaseContext p) { _logger = logger; _database = p; }
public UniversityRepository(ProjectDatabaseContext context) { _context = context; }
public LoginController(ProjectDatabaseContext projectdatabasecontext) { _database = projectdatabasecontext; }
public HiringManagerController(ILogger <HomeController> logger, ProjectDatabaseContext p) { _logger = logger; _database = p; }
public SearchController() { _searchContext = new ProjectDatabaseContext(); }