public ActionResult UpdateCategoryStatus(int CategoryID, int status) { var emailid = User.Identity.Name.ToString(); Users admin = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault(); NoteCategories obj = dbobj.NoteCategories.Where(x => x.ID == CategoryID).FirstOrDefault(); if (status == 0) // Deactivate Category { obj.IsActive = false; obj.ModifiedDate = DateTime.Now; obj.ModifiedBy = admin.ID; } else // Activate Category { obj.IsActive = true; obj.ModifiedDate = DateTime.Now; obj.ModifiedBy = admin.ID; } dbobj.Entry(obj).State = System.Data.Entity.EntityState.Modified; dbobj.SaveChanges(); return(RedirectToAction("ManageCategory")); }
//get public ActionResult addcategory(int?id) { NMEntities nm = new NMEntities(); NoteCategories catdata = nm.NoteCategories.Where(x => x.NoteCategoryID == id).FirstOrDefault(); return(View(catdata)); }
public ActionResult NoteDetails_Admin(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SellerNotes sellerNote = objNotesEntities.SellerNotes.Find(id); if (sellerNote == null) { return(HttpNotFound()); } Country country = objNotesEntities.Country.Find(sellerNote.Country); NoteCategories category = objNotesEntities.NoteCategories.Find(sellerNote.NoteCategory); SellerNotesAttachements attechment = objNotesEntities.SellerNotesAttachements.Where(x => x.NoteID == sellerNote.ID).FirstOrDefault(); if (country == null) { ViewBag.Country = null; } else { ViewBag.Country = country.CountryName; } var data = objNotesEntities.SellerNotes.Where(x => x.ID == id).FirstOrDefault(); ViewBag.dispic = data.DisplayPicture; ViewBag.notepre = data.PreviewUpload; ViewBag.Category = category.CategoryName; ViewBag.Attchment = attechment.FilePath; return(View(data)); }
public ActionResult addCategory(int?id) { NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities(); NoteCategories catdata = DBobj.NoteCategories.Where(x => x.NoteCategoryID == id).FirstOrDefault(); return(View(catdata)); }
public bool AddCategoriesToNote(NoteCategoriesCreate model) { var entity = new NoteCategories() { NoteID = model.NoteID, CategoryID = model.CategoryID, }; using (var ctx = new ApplicationDbContext()) { ctx.NoteCategories.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult addcategory(NoteCategories catergory) { using (NMEntities nm = new NMEntities()) { NoteCategories ng = new NoteCategories(); ng.CategoryName = catergory.CategoryName; ng.Description = catergory.Description; ng.IsActive = true; ng.CreatedDate = DateTime.Now; nm.NoteCategories.Add(ng); nm.SaveChanges(); ModelState.Clear(); } return(View()); }
public ActionResult EditCategory(int CategoryID) { var emailid = User.Identity.Name.ToString(); Users admin = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault(); NoteCategories obj = dbobj.NoteCategories.Where(x => x.ID == CategoryID).FirstOrDefault(); AddCategory model = new AddCategory(); model.CategoryID = obj.ID; model.CategoryName = obj.Name; model.Description = obj.Description; ViewBag.ProfilePicture = dbobj.Admin.Where(x => x.UserID == admin.ID).Select(x => x.ProfilePicture).FirstOrDefault(); return(View(model)); }
public ActionResult addCategory(NoteCategories model) { if (ModelState.IsValid) { using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities()) { NoteCategories nc = new NoteCategories(); nc.CategoryName = model.CategoryName; nc.Description = model.Description; nc.IsActive = true; nc.CreatedDate = DateTime.Now; DBobj.NoteCategories.Add(nc); DBobj.SaveChanges(); ModelState.Clear(); ViewBag.categorySuccess = "<p><span><i class='fas fa-check-circle'></i></span> Category added successfully.</p>"; } } return(View()); }
public ActionResult EditCategory(AddCategory model) { var emailid = User.Identity.Name.ToString(); Users admin = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault(); if (ModelState.IsValid) { NoteCategories obj = dbobj.NoteCategories.Where(x => x.ID == model.CategoryID).FirstOrDefault(); obj.Name = model.CategoryName; obj.Description = model.Description; obj.ModifiedDate = DateTime.Now; obj.ModifiedBy = admin.ID; dbobj.Entry(obj).State = System.Data.Entity.EntityState.Modified; dbobj.SaveChanges(); return(RedirectToAction("ManageCategory")); } ViewBag.ProfilePicture = dbobj.Admin.Where(x => x.UserID == admin.ID).Select(x => x.ProfilePicture).FirstOrDefault(); return(View()); }
//GET: NoteDetails public ActionResult noteDetails(int id) { using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities()) { var ni = DBobj.NoteDetails.Where(x => x.NoteID == id).FirstOrDefault(); NoteCategories noteCategory = DBobj.NoteCategories.Find(ni.NoteCategoryID); ViewBag.Category = noteCategory.CategoryName; Countries country = DBobj.Countries.Find(ni.CountryID); ViewBag.Country = country.CountryName; var reviewdetail = (from nr in DBobj.NoteReviews join n in DBobj.NoteDetails on nr.NoteID equals n.NoteID join us in DBobj.Users on nr.ReviewByID equals us.UserID orderby nr.CreatedDate descending select new MyProgressNotes { SellerNotes = n, noteReview = nr, u = us }).Take(3).ToList(); ViewBag.reviewdetailbag = reviewdetail; ViewBag.reviewcount = reviewdetail.Count(); ViewBag.ratingCount = DBobj.NoteReviews.Where(x => x.NoteID == id).Select(x => x.Ratings).Count(); if (ViewBag.ratingcount > 0) { ViewBag.ratingSum = DBobj.NoteReviews.Where(x => x.NoteID == id).Select(x => x.Ratings).Sum(); } else { ViewBag.ratingSum = "No Review Found !"; } ViewBag.spamtotalcount = DBobj.SpamReports.Where(x => x.NoteID == id).Count(); return(View(ni)); } }
public ActionResult AddCategory(ManageCategoryViewModel category) { var user = db.Users.FirstOrDefault(x => x.Email == User.Identity.Name); if (ModelState.IsValid) { //add data into category table NoteCategories Notes = new NoteCategories(); Notes.Name = category.categoryName; Notes.Description = category.description; Notes.CreatedDate = DateTime.Now; Notes.CreatedBy = user.ID; Notes.IsActive = true; db.NoteCategories.Add(Notes); db.SaveChanges(); return(RedirectToAction("ManageCategory")); } return(View()); }
public ActionResult AddCategory(AddCategory obj) { if (ModelState.IsValid) { var user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault(); NoteCategories noteCategory = new NoteCategories { Name = obj.Name.Trim(), Description = obj.Description.Trim(), CreatedDate = DateTime.Now, CreatedBy = user.ID, IsActive = true }; dobj.NoteCategories.Add(noteCategory); dobj.SaveChanges(); return(RedirectToAction("ManageCategory")); } else { return(View(obj)); } }
public ActionResult managecategory(NoteCategories model) { return(View()); }
public ActionResult Download(int noteId, int userId) { //Download the file var user = db.Users.FirstOrDefault(x => x.Email == User.Identity.Name); //check its member or admin if (user.RoleID == 3 || userId == user.ID || user.RoleID == 4) { return(RedirectToAction("AdminDownload", "AdminDownloadNote", new { noteId = noteId, userId = userId })); } if (Session["ID"] == null) { return(RedirectToAction("Login", "Account")); } //check user enter the profile details or not bool temp = db.UserProfile.Any(x => x.UserID == user.ID); if (!temp) { return(RedirectToAction("MyProfile", "UserProfile")); } //count notes for zip or simple note download var note = db.SellerNotes.Find(noteId); var count = db.SellerNotesAttachements.Where(x => x.NoteID == noteId).Count(); string notesattachementpath = "~/Members/" + userId + "/" + noteId + "/Attachements/"; if (count > 1) { var noteattachement = db.SellerNotesAttachements.Where(x => x.NoteID == note.ID).ToList(); } //full path for download file string filename = db.SellerNotesAttachements.FirstOrDefault(x => x.NoteID == noteId).FileName; string attachmentspath = notesattachementpath + filename; string fullpath = System.IO.Path.Combine(notesattachementpath, filename); //when user first time download if (!db.Downloads.Any(x => x.NoteID == noteId && x.Downloader == user.ID)) { //Save data in database SellerNotes obj = new SellerNotes(); NoteCategories cat = new NoteCategories(); int category = db.SellerNotes.FirstOrDefault(x => x.ID == noteId).Category; string title = db.SellerNotes.FirstOrDefault(x => x.ID == noteId).Title; Downloads downloadnotedetail = new Downloads(); downloadnotedetail.NoteID = noteId; downloadnotedetail.Seller = userId; downloadnotedetail.Downloader = user.ID; downloadnotedetail.AttachmentPath = notesattachementpath; downloadnotedetail.NoteTitle = title; downloadnotedetail.NoteCategory = db.NoteCategories.FirstOrDefault(x => x.ID == category).Name; downloadnotedetail.CreatedDate = DateTime.Now; downloadnotedetail.CreatedBy = user.ID; downloadnotedetail.AttachmentDownloadedDate = DateTime.Now; downloadnotedetail.IsActive = true; var notes = db.SellerNotes.FirstOrDefault(x => x.ID == noteId); if (notes.IsPaid) { downloadnotedetail.IsSellerHasAllowedDownload = false; downloadnotedetail.IsAttachmentDownloaded = false; downloadnotedetail.IsPaid = true; downloadnotedetail.PurchasedPrice = db.SellerNotes.FirstOrDefault(x => x.ID == noteId).SellingPrice; db.Downloads.Add(downloadnotedetail); db.SaveChanges(); return(RedirectToAction("NoteDetails", new { id = noteId })); } downloadnotedetail.IsSellerHasAllowedDownload = true; downloadnotedetail.IsAttachmentDownloaded = true; downloadnotedetail.PurchasedPrice = 0; downloadnotedetail.IsPaid = false; db.Downloads.Add(downloadnotedetail); db.SaveChanges(); } //check allow download var res = db.Downloads.FirstOrDefault(x => x.NoteID == noteId && x.Downloader == user.ID); if (res.IsSellerHasAllowedDownload == false && res.IsPaid == true) { int userOfNote = db.SellerNotes.FirstOrDefault(x => x.ID == noteId).SellerID; string name = db.Users.FirstOrDefault(x => x.ID == userOfNote).FirstName; string fullName = user.FirstName + " " + user.LastName; forallowdownload(name, fullName); //set temp data for popup box TempData["Requested"] = "Requested"; return(RedirectToAction("NoteDetails", new { id = noteId })); } Downloads forModifydata = new Downloads(); forModifydata.IsAttachmentDownloaded = true; forModifydata.ModifiedDate = DateTime.Now; forModifydata.ModifiedBy = user.ID; forModifydata.AttachmentDownloadedDate = DateTime.Now; db.SaveChanges(); //for multiple file if (count > 1) { string path = Server.MapPath(notesattachementpath); DirectoryInfo dir = new DirectoryInfo(path); using (var memoryStream = new MemoryStream()) { using (var ziparchive = new ZipArchive(memoryStream, System.IO.Compression.ZipArchiveMode.Create, true)) { foreach (var item in dir.GetFiles()) { string filepath = path + item.ToString(); ziparchive.CreateEntryFromFile(filepath, item.ToString()); } } return(File(memoryStream.ToArray(), "application/zip", note.Title + ".zip")); } } //for only one file return(File(fullpath, "application/pdf", filename)); }