Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
 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();
         }
     }
 }
Ejemplo n.º 3
0
        //
        // 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");
            }
        }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
 //
 // 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());
     }
 }
Ejemplo n.º 6
0
 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});
     }
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
        //
        // 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");
        }
Ejemplo n.º 9
0
 //
 // 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");
 }
Ejemplo n.º 10
0
 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");
     }
 }
Ejemplo n.º 11
0
        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");
        }
Ejemplo n.º 12
0
        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});
            }
        }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
 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");
     }
 }
Ejemplo n.º 15
0
 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();
         }
     }
 }
Ejemplo n.º 16
0
 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");
     }
 }
Ejemplo n.º 17
0
        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();
        }
Ejemplo n.º 18
0
 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();
     }
 }
Ejemplo n.º 19
0
 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();
 }
Ejemplo n.º 20
0
        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");
            }
        }
Ejemplo n.º 21
0
 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();
 }
Ejemplo n.º 22
0
 public RequestsController(ProjectDatabaseContext context)
 {
     _context = context;
 }
Ejemplo n.º 23
0
 public SetupController()
 {
     _setupContext = new ProjectDatabaseContext();
 }
Ejemplo n.º 24
0
 public ItemDetailsController(ProjectDatabaseContext context)
 {
     _context = context;
 }
Ejemplo n.º 25
0
 public AuthorsController(ProjectDatabaseContext context)
 {
     _context = context;
 }
 public StockController()
 {
     _stockContext = new ProjectDatabaseContext();
 }
Ejemplo n.º 27
0
 public StudentsController(ProjectDatabaseContext context)
 {
     _context = context;
 }
Ejemplo n.º 28
0
 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;
 }
Ejemplo n.º 34
0
 public SearchController()
 {
     _searchContext = new ProjectDatabaseContext();
 }