コード例 #1
0
        public ActionResult UpdateAdminStatus(int uid, int status)
        {
            var   emailid    = User.Identity.Name.ToString();
            Users superadmin = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            Users obj   = dbobj.Users.Where(x => x.ID == uid).FirstOrDefault();
            Admin adobj = dbobj.Admin.Where(x => x.UserID == uid).FirstOrDefault();

            if (status == 0)    // Deactivate Admin
            {
                obj.IsActive     = false;
                obj.ModifiedDate = DateTime.Now;
                obj.ModifiedBy   = superadmin.ID;

                adobj.IsActive     = false;
                adobj.ModifiedDate = DateTime.Now;
                adobj.ModifiedBy   = superadmin.ID;
            }
            else    // Activate Admin
            {
                obj.IsActive     = true;
                obj.ModifiedDate = DateTime.Now;
                obj.ModifiedBy   = superadmin.ID;

                adobj.IsActive     = true;
                adobj.ModifiedDate = DateTime.Now;
                adobj.ModifiedBy   = superadmin.ID;
            }

            dbobj.Entry(obj).State   = System.Data.Entity.EntityState.Modified;
            dbobj.Entry(adobj).State = System.Data.Entity.EntityState.Modified;
            dbobj.SaveChanges();

            return(RedirectToAction("ManageAdmin"));
        }
コード例 #2
0
        public ActionResult Deactivate(int uid)
        {
            var   emailid = User.Identity.Name.ToString();
            Users obj     = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            Users       userobj = dbobj.Users.Where(x => x.ID == uid).FirstOrDefault();
            UserProfile upobj   = dbobj.UserProfile.Where(x => x.UserID == uid).FirstOrDefault();

            userobj.IsActive = false;
            upobj.IsActive   = false;

            var usernotes = dbobj.SellerNotes.Where(x => x.SellerID == uid);

            foreach (var item in usernotes)
            {
                item.IsActive           = false;
                dbobj.Entry(item).State = System.Data.Entity.EntityState.Modified;
            }

            /*var user_notes_attachments = dbobj.NoteTable.Where(x => x.UID == uid);
             *
             * foreach (var item in user_notes_attachments)
             * {
             *  item.IsActive = false;
             * }*/

            dbobj.Entry(userobj).State = System.Data.Entity.EntityState.Modified;
            dbobj.Entry(upobj).State   = System.Data.Entity.EntityState.Modified;

            dbobj.SaveChanges();

            return(RedirectToAction("AllMembers"));
        }
コード例 #3
0
        public ActionResult SignUp(Models.UsersModel model)
        {
            if (ModelState.IsValid)
            {
                var isExist = IsEmailExist(model.EmailID);
                if (isExist)
                {
                    ModelState.AddModelError("Email", "Email already exist");
                    return(View(model));
                }

                Users obj = new Users();
                obj.RoleID          = 3;
                obj.FirstName       = model.FirstName;
                obj.LastName        = model.LastName;
                obj.EmailID         = model.EmailID;
                obj.Password        = model.Password;
                obj.IsEmailVerified = model.IsEmailVerified;
                obj.IsActive        = model.IsActive;
                obj.SecretCode      = Guid.NewGuid();

                dbobj.Users.Add(obj);
                dbobj.SaveChanges();
                SendVerificationLinkEmail(model.EmailID, model.FirstName, obj.SecretCode.ToString());
                TempData["Success"] = "Your account has been successfully created.";
            }
            ModelState.Clear();

            return(RedirectToAction("SignUp"));
        }
コード例 #4
0
        public ActionResult addType(NoteType model)
        {
            int id = (int)Session["UserID"];

            if (ModelState.IsValid)
            {
                using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())
                {
                    NoteType notetype = new NoteType();
                    notetype.TypeName     = model.TypeName;
                    notetype.Description  = model.Description;
                    notetype.IsActive     = true;
                    notetype.ModifiedBy   = id;
                    notetype.ModifiedDate = DateTime.Now;
                    notetype.CreatedDate  = DateTime.Now;
                    notetype.CreatedBy    = id;

                    DBobj.NoteType.Add(notetype);
                    DBobj.SaveChanges();

                    ModelState.Clear();
                    ViewBag.typeSuccess = "<p><span><i class='fas fa-check-circle'></i></span> Type added successfully.</p>";
                }
            }
            return(View());
        }
コード例 #5
0
 public ActionResult UpdatePassword(User user)
 {
     if (Session["userId"] == null)
     {
         return(RedirectToAction("Login", "Auth"));
     }
     else
     {
         int  userId      = (int)Session["userID"];
         User currentUser = data.Users.Find(user.UserID);
         if (user.Password.Equals(currentUser.Password))
         {
             currentUser.Password           = user.NewPassword;
             currentUser.ConfirmPassword    = user.NewPassword;
             currentUser.NewPassword        = user.NewPassword;
             currentUser.ConfirmNewPassword = user.NewPassword;
             data.Entry(currentUser).State  = System.Data.Entity.EntityState.Modified;
             data.SaveChanges();
             return(RedirectToAction("Login", "Auth"));
         }
         else
         {
             return(Content("The Old Password Not Matched !!!"));
             //return RedirectToAction("ChangePassword", "Auth");
         }
     }
 }
コード例 #6
0
        public ActionResult addAdministrator(adminSignUp model)
        {
            if (ModelState.IsValid)
            {
                using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())
                {
                    Users u = new Users();
                    u.FirstName       = model.FirstName;
                    u.LastName        = model.LastName;
                    u.EmailID         = model.EmailID;
                    u.UserRoleID      = 2;
                    u.IsActive        = true;
                    u.CreatedDate     = DateTime.Now;
                    u.Password        = "******";
                    u.IsEmailVerified = true;

                    DBobj.Users.Add(u);
                    DBobj.SaveChanges();

                    if (u.UserID > 0)
                    {
                        UserProfile up = new UserProfile();
                        up.UserID       = u.UserID;
                        up.CountryCode  = model.CountryCode;
                        up.PhoneNumber  = model.PhoneNumber;
                        up.AddressLine1 = "null";
                        up.City         = "null";
                        up.State        = "null";
                        up.ZipCode      = "null";
                        up.CountryID    = 1;
                        up.CreatedDate  = DateTime.Now;
                        up.IsActive     = true;

                        DBobj.UserProfile.Add(up);
                        DBobj.SaveChanges();
                        ModelState.Clear();
                        var countrycode = DBobj.Countries.ToList();
                        ViewBag.countryCode = new SelectList(countrycode, "CountryCode", "CountryCode");
                        ViewBag.IsSuccess   = "<p><span><i class='fas fa-check-circle'></i></span> Admin added successfully.</p>";
                    }
                }
            }

            return(View());
        }
コード例 #7
0
        //GET: DeleteType
        public ActionResult deleteType(int id)
        {
            NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities();
            var typedetail = DBobj.NoteType.Where(x => x.NoteTypeID == id).FirstOrDefault();

            typedetail.IsActive = false;
            DBobj.SaveChanges();
            return(RedirectToAction("manageType", "Admin"));
        }
コード例 #8
0
        //GET: DeleteAdmin
        public ActionResult deleteAdmin(int id)
        {
            NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities();
            var admindetail = DBobj.Users.Where(x => x.UserID == id).FirstOrDefault();

            admindetail.IsActive = false;
            DBobj.SaveChanges();
            return(RedirectToAction("manageAdministrator", "Admin"));
        }
コード例 #9
0
        //GET: DeleteCountry
        public ActionResult deleteCountry(int id)
        {
            NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities();
            var countrydetail = DBobj.Countries.Where(x => x.CountryID == id).FirstOrDefault();

            countrydetail.IsActive = false;
            DBobj.SaveChanges();
            return(RedirectToAction("manageCountry", "Admin"));
        }
コード例 #10
0
        public ActionResult DeleteSpamReports(int sid)
        {
            SpamTable report = dbobj.SpamTable.Where(x => x.ID == sid).FirstOrDefault();
            int       nid    = report.NoteID;

            dbobj.SpamTable.Remove(report);
            dbobj.SaveChanges();

            var book = dbobj.SellerNotes.Where(x => x.ID == nid).FirstOrDefault();

            int total_spams = dbobj.SpamTable.Where(x => x.NoteID == nid).Count();

            book.TotalSpams = total_spams;

            dbobj.Entry(book).State = System.Data.Entity.EntityState.Modified;
            dbobj.SaveChanges();

            return(RedirectToAction("SpamReports"));
        }
コード例 #11
0
        public ActionResult AddCountry(AddCountry model)
        {
            var   emailid = User.Identity.Name.ToString();
            Users admin   = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            if (ModelState.IsValid)
            {
                Countries obj = new Countries();
                obj.Name        = model.CountryName;
                obj.CountryCode = model.CountryCode;
                obj.CreatedDate = DateTime.Now;
                obj.CreatedBy   = admin.ID;
                obj.IsActive    = true;

                dbobj.Countries.Add(obj);
                dbobj.SaveChanges();

                return(RedirectToAction("ManageCountries"));
            }
            return(View());
        }
コード例 #12
0
        public ActionResult AddCategory(AddCategory model)
        {
            var   emailid = User.Identity.Name.ToString();
            Users admin   = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            if (ModelState.IsValid)
            {
                NoteCategories obj = new NoteCategories();
                obj.Name        = model.CategoryName;
                obj.Description = model.Description;
                obj.CreatedDate = DateTime.Now;
                obj.CreatedBy   = admin.ID;
                obj.IsActive    = true;

                dbobj.NoteCategories.Add(obj);
                dbobj.SaveChanges();

                return(RedirectToAction("ManageCategory"));
            }
            ViewBag.ProfilePicture = dbobj.Admin.Where(x => x.UserID == admin.ID).Select(x => x.ProfilePicture).FirstOrDefault();
            return(View());
        }
コード例 #13
0
        public ActionResult AllowDownload(int tid)
        {
            var   emailid = User.Identity.Name.ToString();
            Users obj     = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            Transection deal = dbobj.Transection.Where(x => x.ID == tid).FirstOrDefault();

            deal.IsAllowed = true;

            dbobj.Entry(deal).State = System.Data.Entity.EntityState.Modified;
            dbobj.SaveChanges();
            NotifyBuyer(deal.Users.EmailID, deal.Users.FirstName, obj.FirstName);

            return(RedirectToAction("BuyerRequest"));
        }
コード例 #14
0
        public ActionResult DeleteBook(int noteid)
        {
            SellerNotesAttachements attachment = dbobj.SellerNotesAttachements.Where(x => x.NoteID == noteid).FirstOrDefault();
            SellerNotes             noteobj    = dbobj.SellerNotes.Where(x => x.ID == noteid).FirstOrDefault();

            string mappedPath = Server.MapPath("/Members/" + noteobj.SellerID + "/" + noteid);

            Directory.Delete(mappedPath, true);

            dbobj.SellerNotesAttachements.Remove(attachment);
            dbobj.SellerNotes.Remove(noteobj);
            dbobj.SaveChanges();

            return(RedirectToAction("Dashboard"));
        }
コード例 #15
0
        public ActionResult changePassword(ChangePass cp)
        {
            using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())

            {
                int   id = (int)Session["UserID"];
                Users u  = DBobj.Users.Where(x => x.UserID == id).FirstOrDefault();
                if (u.Password == cp.Password)
                {
                    u.Password = cp.NewPassword;
                    DBobj.SaveChanges();
                    ViewBag.PassMessage = "<p><span><i class='fas fa-check-circle'></i></span> Your Password has been Changed successfully</p>";
                }
            }
            return(View());
        }
コード例 #16
0
        public ActionResult ContactUs(Models.ContactUsModel model)
        {
            if (ModelState.IsValid)
            {
                ContactUs obj = new ContactUs();
                obj.FullName = model.FullName;
                obj.EmailID  = model.EmailID;
                obj.Subjects = model.Subject;
                obj.Comments = model.Comments;

                dbobj.ContactUs.Add(obj);
                dbobj.SaveChanges();
                SendEmailToAdmin(obj);
            }
            ModelState.Clear();
            return(RedirectToAction("ContactUs"));
        }
コード例 #17
0
 //GET: InReviewNotes
 public ActionResult inReviewNotes(int id)
 {
     using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())
     {
         NoteDetails note = DBobj.NoteDetails.FirstOrDefault(x => x.NoteID == id);
         if (note != null)
         {
             note.Status        = 5;
             note.PublishedDate = DateTime.Now;
             note.ActionBy      = (int)Session["UserID"];
             note.ModifiedBy    = (int)Session["UserID"];
             note.ModifiedDate  = DateTime.Now;
             DBobj.SaveChanges();
         }
         return(RedirectToAction("notesUnderReview", "Admin"));
     }
 }
コード例 #18
0
        public ActionResult AddAdmin(Models.AddAdmin model)
        {
            var   emailid = User.Identity.Name.ToString();
            Users admin   = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            if (ModelState.IsValid)
            {
                var isExist = IsEmailExist(model.Email);
                if (isExist)
                {
                    ModelState.AddModelError("Email", "Email already exist");
                    ViewBag.CountryCode = new SelectList(dbobj.Countries, "CountryCode", "CountryCode");
                    return(View(model));
                }

                Users obj = new Users();
                obj.RoleID    = 2;
                obj.FirstName = model.FirstName;
                obj.LastName  = model.LastName;
                obj.EmailID   = model.Email;
                string pwd = Membership.GeneratePassword(6, 2);
                obj.Password        = pwd;
                obj.IsEmailVerified = true;
                obj.CreatedData     = DateTime.Now;
                obj.CreatedBy       = admin.ID;
                obj.IsActive        = true;

                Admin adobj = new Admin();
                adobj.UserID      = obj.ID;
                adobj.CountryCode = model.CountryCode;
                adobj.PhoneNumber = model.PhoneNumber;
                adobj.CreatedDate = DateTime.Now;
                adobj.CreatedBy   = admin.ID;
                adobj.IsActive    = true;

                dbobj.Users.Add(obj);
                dbobj.Admin.Add(adobj);
                dbobj.SaveChanges();

                SendPasswordToAdmin(model.Email, pwd);

                return(RedirectToAction("ManageAdmin", "Admin"));
            }
            return(View());
        }
コード例 #19
0
        public ActionResult deactivateUser(int uid)
        {
            using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())
            {
                Users udetail = DBobj.Users.Where(x => x.UserID == uid).FirstOrDefault();
                IQueryable <NoteDetails> ndetail = DBobj.NoteDetails.Where(x => x.SellerID == uid);
                foreach (var i in ndetail)
                {
                    i.IsActive = false;
                    SellerNoteAttachment nddetails = DBobj.SellerNoteAttachment.Where(x => x.NoteID == i.NoteID).FirstOrDefault();
                    nddetails.IsActive = false;
                }
                udetail.IsActive = false;

                DBobj.SaveChanges();
                return(View("members", "Admin"));
            }
        }
コード例 #20
0
        public ActionResult AdminProfile(NotesMarketplace.Models.AdminProfile model)
        {
            var   emailid = User.Identity.Name.ToString();
            Users obj     = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            var apobj = dbobj.Admin.Where(x => x.UserID == obj.ID).FirstOrDefault();

            obj.FirstName        = model.FirstName;
            obj.LastName         = model.LastName;
            obj.EmailID          = model.Email;
            apobj.SecondaryEmail = model.SecondaryEmail;
            apobj.CountryCode    = model.CountryCode;
            apobj.PhoneNumber    = model.PhoneNumber;

            string path = Path.Combine(Server.MapPath("~/Members"), obj.ID.ToString());

            //Checking for directory

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            //Saving Profile Picture
            if (model.ProfilePicture != null && model.ProfilePicture.ContentLength > 0)
            {
                var ProfilePicture = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + Path.GetExtension(model.ProfilePicture.FileName);
                var ImageSavePath  = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/") + "DP_" + ProfilePicture);
                model.ProfilePicture.SaveAs(ImageSavePath);
                apobj.ProfilePicture = Path.Combine(("Members/" + obj.ID + "/"), "DP_" + ProfilePicture);
            }
            else
            {
                apobj.ProfilePicture = dbobj.SystemConfigurations.Where(x => x.Key == "DefaultProfilePicture").Select(x => x.Value).ToString();
            }

            dbobj.Entry(obj).State   = System.Data.Entity.EntityState.Modified;
            dbobj.Entry(apobj).State = System.Data.Entity.EntityState.Modified;
            dbobj.SaveChanges();

            return(RedirectToAction("AdminDashboard", "Admin"));
        }
コード例 #21
0
 //GET: Unpublish Note
 public ActionResult unPublishNote(int id, string adminRemarks)
 {
     using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())
     {
         NoteDetails note = DBobj.NoteDetails.FirstOrDefault(x => x.NoteID == id);
         Users       u    = DBobj.Users.Where(x => x.UserID == note.SellerID).FirstOrDefault();
         if (note != null)
         {
             note.Status        = 6;
             note.AdminRemarks  = adminRemarks;
             note.PublishedDate = DateTime.Now;
             note.ActionBy      = (int)Session["UserID"];
             note.ModifiedBy    = (int)Session["UserID"];
             note.ModifiedDate  = DateTime.Now;
             DBobj.SaveChanges();
             unPublishNoteToUser.unpublishNote(u.FirstName, u.EmailID, adminRemarks);
         }
         return(RedirectToAction("dashboard", "Admin"));
     }
 }
コード例 #22
0
        public ActionResult addCountry(Countries model)
        {
            if (ModelState.IsValid)
            {
                using (NotesMarketplaceEntities DBobj = new NotesMarketplaceEntities())
                {
                    Countries cr = new Countries();
                    cr.CountryCode = model.CountryCode;
                    cr.CountryName = model.CountryName;
                    cr.IsActive    = true;
                    cr.CreatedDate = DateTime.Now;

                    DBobj.Countries.Add(cr);
                    DBobj.SaveChanges();

                    ModelState.Clear();
                    ViewBag.countrySuccess = "<p><span><i class='fas fa-check-circle'></i></span> Country added successfully.</p>";
                }
            }
            return(View());
        }
コード例 #23
0
        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());
        }
コード例 #24
0
        public ActionResult AddReview(int nid, int rate, string Comments)
        {
            var   emailid = User.Identity.Name.ToString();
            Users obj     = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            var oldreview = dbobj.SellerNotesReviews.Where(x => x.NoteID == nid && x.ReviewedByID == obj.ID).FirstOrDefault();

            if (oldreview == null)   //New Review
            {
                SellerNotesReviews review = new SellerNotesReviews();

                review.NoteID       = nid;
                review.ReviewedByID = obj.ID;
                review.Ratings      = rate;
                review.Comments     = Comments;
                review.CreatedDate  = DateTime.Now;

                dbobj.SellerNotesReviews.Add(review);
                dbobj.SaveChanges();

                // Adding Ratings in note table

                var book = dbobj.SellerNotes.Where(x => x.ID == nid).FirstOrDefault();

                int     total_reviews = dbobj.SellerNotesReviews.Where(x => x.NoteID == nid).Count();
                decimal total_stars   = dbobj.SellerNotesReviews.Where(x => x.NoteID == nid).Select(x => x.Ratings).Sum();

                book.TotalReviews = total_reviews;
                book.Rating       = ((double)total_stars / total_reviews) * 20;

                dbobj.Entry(book).State = System.Data.Entity.EntityState.Modified;
                dbobj.SaveChanges();

                // ------------------------------------------------------------

                return(RedirectToAction("MyDownloads"));
            }
            else   //Update Review
            {
                oldreview.Ratings  = rate;
                oldreview.Comments = Comments;

                dbobj.Entry(oldreview).State = System.Data.Entity.EntityState.Modified;
                dbobj.SaveChanges();

                // Adding Ratings in note table

                var book = dbobj.SellerNotes.Where(x => x.ID == nid).FirstOrDefault();

                int     total_reviews = dbobj.SellerNotesReviews.Where(x => x.NoteID == nid).Count();
                decimal total_stars   = dbobj.SellerNotesReviews.Where(x => x.NoteID == nid).Select(x => x.Ratings).Sum();

                book.TotalReviews = total_reviews;
                book.Rating       = ((double)total_stars / total_reviews) * 20;

                dbobj.Entry(book).State = System.Data.Entity.EntityState.Modified;
                dbobj.SaveChanges();

                // ------------------------------------------------------------

                return(RedirectToAction("MyDownloads"));
            }
        }
コード例 #25
0
        public ActionResult AddNotes(NotesDetail notesDetail)
        {
            if (userid != 0)
            {
                List <ManageCTC> manageCTCs = db.ManageCTCs.ToList();
                ViewBag.MyCTC = manageCTCs;
                if (notesDetail != null)
                {
                    if (notesDetail.Category.Equals("Select Your category"))
                    {
                        ViewBag.category      = "Select category of note";
                        notesDetail.SellPrice = 0;
                        return(View(notesDetail));
                    }
                    if (notesDetail.NoteType.Equals("Select your mode type"))
                    {
                        notesDetail.NoteType = null;
                    }
                    if (notesDetail.Country.Equals("Select your country"))
                    {
                        notesDetail.Country = null;
                    }
                    if (notesDetail.Note_Attachment == null && notesDetail.NoteAttachment == null)
                    {
                        ViewBag.Note_Attachmen = "Please attach your notes here...";
                        notesDetail.SellPrice  = 0;
                        return(View(notesDetail));
                    }
                    notesDetail.F_K_User    = userid;
                    notesDetail.IsActive    = true;
                    notesDetail.CreatedDate = DateTime.Now;
                    if (notesDetail.Book_Picture != null && (notesDetail.BookPicture == null))
                    {
                        if (notesDetail.Book_Picture.ContentLength > 1024 * 1024 * 10)
                        {
                            ViewBag.Book_Picture  = "File size should be less then 10 MB!";
                            notesDetail.SellPrice = 0;
                            return(View(notesDetail));
                        }
                        string path           = Server.MapPath("~/Uploads/BookPicture/");
                        String extension      = Path.GetExtension(notesDetail.Book_Picture.FileName);
                        var    supportedTypes = new[] { ".jpg", ".jpeg", ".png" };
                        if (supportedTypes.Contains(extension.ToUpper()) || supportedTypes.Contains(extension.ToLower()))
                        {
                            string fileName = userid.ToString() + DateTime.Now.ToString("G").Replace(" ", String.Empty).Replace("-", String.Empty).Replace(":", String.Empty) + extension;
                            notesDetail.Book_Picture.SaveAs(Path.Combine(path, fileName));
                            notesDetail.BookPicture = fileName;
                        }
                        else
                        {
                            ViewBag.Book_Picture  = "Choose images only";
                            notesDetail.SellPrice = 0;
                            return(View(notesDetail));
                        }
                    }
                    if (notesDetail.Note_Attachment != null && notesDetail.NoteAttachment == null)
                    {
                        string path           = Server.MapPath("~/Uploads/Books/");
                        String extension      = Path.GetExtension(notesDetail.Note_Attachment.FileName);
                        var    supportedTypes = new[] { ".pdf" };
                        if (supportedTypes.Contains(extension.ToUpper()) || supportedTypes.Contains(extension.ToLower()))
                        {
                            string fileName = userid.ToString() + DateTime.Now.ToString("G").Replace(" ", String.Empty).Replace("-", String.Empty).Replace(":", String.Empty) + extension;
                            notesDetail.Note_Attachment.SaveAs(Path.Combine(path, fileName));
                            notesDetail.NoteAttachment = fileName;
                            notesDetail.NoteSize       = notesDetail.Note_Attachment.ContentLength;
                        }
                        else
                        {
                            ViewBag.Note_Attachment = "Choose pdf file only";
                            notesDetail.SellPrice   = 0;
                            return(View(notesDetail));
                        }
                    }
                    if (notesDetail.SellPrice != 0 && notesDetail.Note_Preview == null)
                    {
                        ViewBag.Note_Preview  = "Pleasse add note preview here...";
                        notesDetail.SellPrice = 0;
                        return(View(notesDetail));
                    }
                    if (notesDetail.Note_Preview != null && notesDetail.Note_Preview == null)
                    {
                        if (notesDetail.Note_Preview.ContentLength > 1024 * 1024 * 10)
                        {
                            ViewBag.Note_Preview  = "File size should be less then 10 MB!";
                            notesDetail.SellPrice = 0;
                            return(View(notesDetail));
                        }
                        string path           = Server.MapPath("~/Uploads/BookPreview/");
                        String extension      = Path.GetExtension(notesDetail.Note_Preview.FileName);
                        var    supportedTypes = new[] { ".pdf" };
                        if (supportedTypes.Contains(extension.ToUpper()) || supportedTypes.Contains(extension.ToLower()))
                        {
                            string fileName = userid.ToString() + DateTime.Now.ToString("G").Replace(" ", String.Empty).Replace("-", String.Empty).Replace(":", String.Empty) + extension;
                            notesDetail.Note_Preview.SaveAs(Path.Combine(path, fileName));
                            notesDetail.NotePreview = fileName;
                        }
                        else
                        {
                            ViewBag.Note_Preview  = "Choose pdf only";
                            notesDetail.SellPrice = 0;
                            return(View(notesDetail));
                        }
                    }
                    try
                    {
                        if (notesDetail.F_K_NoteStatus == 3 && notesDetail.P_K_Note == 0)
                        {
                            User        user = db.Users.FirstOrDefault(m => m.P_K_User == userid);
                            MailMessage mail = new MailMessage("*****@*****.**", user.EmailId.ToString());
                            mail.Subject = user.FirstName + " " + user.LastName + " sent his note for review";
                            string Body = "Hello Admins, \n\nWe want to inform you that, " + user.FirstName + " " + user.LastName + " sent his note " + notesDetail.Title + " for review.Please look at the notes and take required actions.\n\nRegards,\nNotes Marketplace";
                            mail.Body       = Body;
                            mail.IsBodyHtml = true;

                            SmtpClient smtp = new SmtpClient();
                            smtp.Host = "smtp.gmail.com";
                            smtp.Port = 587;
                            smtp.UseDefaultCredentials = false;

                            NetworkCredential nc = new NetworkCredential("*****@*****.**", "12345678finalpatel");
                            smtp.EnableSsl   = true;
                            smtp.Credentials = nc;
                            smtp.Send(mail);
                        }
                    }
                    catch
                    {
                    }

                    if (notesDetail.P_K_Note == 0)
                    {
                        db.NotesDetails.Add(notesDetail);
                        db.SaveChanges();
                    }
                    else
                    {
                        NotesDetail notesDetail1 = db.NotesDetails.FirstOrDefault(m => m.P_K_Note == notesDetail.P_K_Note);
                        if (notesDetail1 != null)
                        {
                            notesDetail1.F_K_NoteStatus   = notesDetail.F_K_NoteStatus;
                            notesDetail1.F_K_User         = notesDetail.F_K_User;
                            notesDetail1.BookPicture      = notesDetail.BookPicture;
                            notesDetail1.Category         = notesDetail.Category;
                            notesDetail1.Country          = notesDetail.Country;
                            notesDetail1.Course           = notesDetail.Course;
                            notesDetail1.CourseCode       = notesDetail.CourseCode;
                            notesDetail1.InstitutionName  = notesDetail.InstitutionName;
                            notesDetail1.ModifiedDate     = DateTime.Now;
                            notesDetail1.NoteAttachment   = notesDetail.NoteAttachment;
                            notesDetail1.NotePreview      = notesDetail.NotePreview;
                            notesDetail1.NotesDescription = notesDetail1.NotesDescription;
                            notesDetail1.NoteSize         = notesDetail.Note_Attachment.ContentLength;
                            notesDetail1.NoteType         = notesDetail.NoteType;
                            notesDetail1.NumberOfPages    = notesDetail.NumberOfPages;
                            notesDetail1.Professor        = notesDetail.Professor;
                            notesDetail1.SellPrice        = notesDetail.SellPrice;
                            notesDetail1.Title            = notesDetail.Title;
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    return(View());
                }
                return(RedirectToAction("Dashboard", "Home"));
            }
            else
            {
                return(HttpNotFound());
            }
        }
コード例 #26
0
        public ActionResult AddNotes(Models.AddNotes model, string submitButton)
        {
            var   emailID = User.Identity.Name.ToString();
            Users obj     = dbobj.Users.Where(x => x.EmailID == emailID).FirstOrDefault();

            if (ModelState.IsValid)
            {
                if (model.ID == null)
                {
                    if ((model.File[0] == null) || ((model.IsPaid == true) && (model.PreviewAttachment == null)))
                    {
                        if (model.File[0] == null)
                        {
                            ModelState.AddModelError("File", "File Required");
                        }
                        if (model.PreviewAttachment == null)
                        {
                            ModelState.AddModelError("PreviewAttachment", "PreviewAttachment Required");
                        }
                        ViewBag.Category       = new SelectList(dbobj.NoteCategories, "ID", "Name");
                        ViewBag.Type           = new SelectList(dbobj.NoteTypes, "ID", "Name");
                        ViewBag.Country        = new SelectList(dbobj.Countries, "ID", "Name");
                        ViewBag.ProfilePicture = dbobj.UserProfile.Where(x => x.UserID == obj.RoleID).Select(x => x.ProfilePicture).FirstOrDefault();

                        return(View(model));
                    }
                    string path = Path.Combine(Server.MapPath("~/Members"), obj.ID.ToString());

                    //Checking for directory

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    SellerNotes noteobj = new SellerNotes();
                    noteobj.SellerID       = obj.ID;
                    noteobj.Title          = model.Title;
                    noteobj.Category       = model.CategoryID;
                    noteobj.NoteType       = model.TypeID;
                    noteobj.NumberofPages  = model.NumberOfPages;
                    noteobj.Description    = model.Description;
                    noteobj.Country        = model.CountryID == null ? 8 : model.CountryID; //if null then country id = 8
                    noteobj.UniversityName = model.InstituteName;
                    noteobj.Course         = model.CourseName == null ? "Other" : model.CourseName;
                    noteobj.CourseCode     = model.CourseCode;
                    noteobj.Professor      = model.Professor;
                    noteobj.IsPaid         = model.IsPaid;
                    noteobj.SellingPrice   = model.Price;
                    if (submitButton == "1")
                    {
                        noteobj.Status = 1;
                    }
                    else
                    {
                        noteobj.Status = 2;
                    }
                    noteobj.ActionedBy  = obj.ID;
                    noteobj.CreatedDate = DateTime.Now;
                    noteobj.IsActive    = true;

                    dbobj.SellerNotes.Add(noteobj);
                    dbobj.SaveChanges();

                    var    NoteID    = noteobj.ID;
                    string finalpath = Path.Combine(Server.MapPath("~/Members/" + obj.ID), NoteID.ToString());

                    if (!Directory.Exists(finalpath))
                    {
                        Directory.CreateDirectory(finalpath);
                    }
                    if (model.DisplayPicture != null && model.DisplayPicture.ContentLength > 0)
                    {
                        var displayimagename = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + Path.GetExtension(model.DisplayPicture.FileName);
                        var ImageSavePath    = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/" + noteobj.ID + "/") + "DP_" + displayimagename);
                        model.DisplayPicture.SaveAs(ImageSavePath);
                        noteobj.DisplayPicture = Path.Combine(("Members/" + obj.ID + "/" + noteobj.ID + "/"), "DP_" + displayimagename);
                        dbobj.SaveChanges();
                    }
                    else
                    {
                        noteobj.DisplayPicture = "Default/Book.jpg";
                        dbobj.SaveChanges();
                    }

                    if (model.PreviewAttachment != null && model.PreviewAttachment.ContentLength > 0)
                    {
                        var notespreviewname = "Preview_" + DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + "_" + Path.GetFileName(model.PreviewAttachment.FileName);
                        var PreviewSavePath  = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/" + noteobj.ID + "/") + notespreviewname);
                        model.PreviewAttachment.SaveAs(PreviewSavePath);
                        noteobj.NotesPreview = Path.Combine(("Members/" + obj.ID + "/" + noteobj.ID + "/") + notespreviewname);
                        dbobj.SaveChanges();
                    }



                    SellerNotesAttachements natobj = new SellerNotesAttachements();
                    natobj.NoteID      = NoteID; //nat stands for note attachment table
                    natobj.IsActive    = true;
                    natobj.CreatedBy   = obj.ID;
                    natobj.CreatedDate = DateTime.Now;

                    string AttachmentPath = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/" + noteobj.ID), "Attachment");

                    if (!Directory.Exists(AttachmentPath))
                    {
                        Directory.CreateDirectory(AttachmentPath);
                    }

                    int counter        = 1;
                    var uploadfilepath = "";
                    var uploadfilename = "";

                    foreach (HttpPostedFileBase file in model.File)
                    {
                        //Checking file is available to save.
                        if (file != null)
                        {
                            var InputFileName  = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + "_" + Path.GetFileName(file.FileName);
                            var ServerSavePath = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/" + noteobj.ID + "/Attachment/") + "Attachment_" + counter + "_" + InputFileName);
                            counter++;
                            //Save file to server folder
                            file.SaveAs(ServerSavePath);
                            uploadfilepath += Path.Combine(("Members/" + obj.ID + "/" + noteobj.ID + "/Attachment/") + "Attachment_" + counter + "_" + InputFileName) + ";";
                            uploadfilename += Path.GetFileName(file.FileName) + ";";
                        }
                    }

                    natobj.FileName = uploadfilename;
                    natobj.FilePath = uploadfilepath;
                    dbobj.SellerNotesAttachements.Add(natobj);
                    dbobj.SaveChanges();
                }
                else //for edit note
                {
                    //saving into database
                    SellerNotes oldnote = dbobj.SellerNotes.Where(x => x.ID == model.ID).FirstOrDefault();
                    oldnote.Title          = model.Title;
                    oldnote.Category       = model.CategoryID;
                    oldnote.NoteType       = model.TypeID;
                    oldnote.NumberofPages  = model.NumberOfPages;
                    oldnote.Description    = model.Description;
                    oldnote.Country        = model.CountryID == null ? 8 : model.CountryID; //if null then country id = 8
                    oldnote.UniversityName = model.InstituteName;
                    oldnote.Course         = model.CourseName == null ? "Other" : model.CourseName;
                    oldnote.CourseCode     = model.CourseCode;
                    oldnote.Professor      = model.Professor;
                    oldnote.IsPaid         = model.IsPaid;
                    oldnote.SellingPrice   = model.Price;

                    if (submitButton == "1")
                    {
                        oldnote.Status = 1;
                    }
                    else
                    {
                        oldnote.Status = 2;
                    }
                    oldnote.ActionedBy   = obj.ID;
                    oldnote.ModifiedDate = DateTime.Now;
                    oldnote.IsActive     = true;

                    dbobj.Entry(oldnote).State = System.Data.Entity.EntityState.Modified;
                    dbobj.SaveChanges();

                    var    NoteID    = oldnote.ID;
                    string finalpath = Path.Combine(Server.MapPath("~/Members/" + obj.ID), NoteID.ToString());

                    //  For New Display Picture
                    if (model.DisplayPicture != null && model.DisplayPicture.ContentLength > 0)
                    {
                        var      OldDisplayPicture = Server.MapPath(oldnote.DisplayPicture);
                        FileInfo file = new FileInfo(OldDisplayPicture);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                        var displayimagename = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + Path.GetExtension(model.DisplayPicture.FileName);
                        var ImageSavePath    = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/" + oldnote.ID + "/") + "DP_" + displayimagename);
                        model.DisplayPicture.SaveAs(ImageSavePath);
                        oldnote.DisplayPicture = Path.Combine(("Members/" + obj.ID + "/" + oldnote.ID + "/"), "DP_" + displayimagename);
                        dbobj.SaveChanges();
                    }

                    //  For New PreviewAttachment
                    if (model.PreviewAttachment != null && model.PreviewAttachment.ContentLength > 0)
                    {
                        var      OldPreviewAttachment = Server.MapPath(oldnote.NotesPreview);
                        FileInfo file = new FileInfo(OldPreviewAttachment);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                        var notespreviewname = "Preview_" + DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + "_" + Path.GetFileName(model.PreviewAttachment.FileName);
                        var PreviewSavePath  = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/" + oldnote.ID + "/") + notespreviewname);
                        model.PreviewAttachment.SaveAs(PreviewSavePath);
                        oldnote.NotesPreview = Path.Combine(("Members/" + obj.ID + "/" + oldnote.ID + "/") + notespreviewname);
                        dbobj.SaveChanges();
                    }

                    if (model.File[0] != null)      // New file Uploaded
                    {
                        SellerNotesAttachements oldnatobj = dbobj.SellerNotesAttachements.Where(x => x.NoteID == NoteID).FirstOrDefault();
                        oldnatobj.ModifiedDate = DateTime.Now;

                        string AttachmentPath = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/" + oldnote.ID), "Attachment");

                        Directory.Delete(AttachmentPath, true);
                        Directory.CreateDirectory(AttachmentPath);

                        int counter        = 1;
                        var uploadfilepath = "";
                        var uploadfilename = "";

                        foreach (HttpPostedFileBase file in model.File)
                        {
                            //Checking file is available to save.
                            if (file != null)
                            {
                                var InputFileName  = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + "_" + Path.GetFileName(file.FileName);
                                var ServerSavePath = Path.Combine(Server.MapPath("Members/" + obj.ID + "/" + oldnote.ID + "/Attachment/") + "Attachment_" + counter + "_" + InputFileName);
                                counter++;
                                //Save file to server folder
                                file.SaveAs(ServerSavePath);
                                uploadfilepath += Path.Combine(("Members/" + obj.ID + "/" + oldnote.ID + "/Attachment/") + "Attachment_" + counter + "_" + InputFileName) + ";";
                                uploadfilename += Path.GetFileName(file.FileName) + ";";
                            }
                        }

                        oldnatobj.FileName           = uploadfilename;
                        oldnatobj.FilePath           = uploadfilepath;
                        dbobj.Entry(oldnatobj).State = System.Data.Entity.EntityState.Modified;
                        dbobj.SaveChanges();
                    }
                }
                return(RedirectToAction("Dashboard", "Dashboard"));
            }
            ViewBag.Category       = new SelectList(dbobj.NoteCategories, "ID", "Name");
            ViewBag.Type           = new SelectList(dbobj.NoteTypes, "ID", "Name");
            ViewBag.Country        = new SelectList(dbobj.Countries, "ID", "Name");
            ViewBag.ProfilePicture = dbobj.UserProfile.Where(x => x.UserID == obj.ID).Select(x => x.ProfilePicture).FirstOrDefault();
            return(View());
        }
コード例 #27
0
        public ActionResult UserProfile(Models.UserProfile model)
        {
            var   emailid = User.Identity.Name.ToString();
            Users obj     = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            if (ModelState.IsValid)
            {
                var isnew = dbobj.UserProfile.Where(x => x.UserID == obj.ID).FirstOrDefault();

                if (isnew == null)   // For new user
                {
                    UserProfile upobj = new UserProfile();
                    upobj.UserID = obj.ID;
                    upobj.DOB    = model.DateOfBirth;
                    upobj.Gender = model.Gender;
                    upobj.PhoneNumberCountryCode = model.CountryCode;
                    upobj.PhoneNumber            = model.PhoneNumber;
                    upobj.AddressLine1           = model.AddressLine1;
                    upobj.AddressLine2           = model.AddressLine2;
                    upobj.City        = model.City;
                    upobj.State       = model.State;
                    upobj.ZipCode     = model.ZipCode;
                    upobj.Country     = model.CountryID;
                    upobj.University  = model.University;
                    upobj.College     = model.College;
                    upobj.CreatedDate = DateTime.Now;
                    upobj.CreatedBy   = obj.ID;
                    upobj.IsActive    = true;

                    string path = Path.Combine(Server.MapPath("~/Members"), obj.ID.ToString());

                    //Checking for directory

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    //Saving Profile Picture
                    if (model.ProfilePicture != null && model.ProfilePicture.ContentLength > 0)
                    {
                        var ProfilePicture = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + Path.GetExtension(model.ProfilePicture.FileName);
                        var ImageSavePath  = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/") + "DP_" + ProfilePicture);
                        model.ProfilePicture.SaveAs(ImageSavePath);
                        upobj.ProfilePicture = Path.Combine(("Members/" + obj.ID + "/"), "DP_" + ProfilePicture);
                        dbobj.SaveChanges();
                    }
                    else
                    {
                        /*upobj.ProfilePicture = "Default/User.jpg";*/
                        upobj.ProfilePicture = dbobj.SystemConfigurations.Where(x => x.Key == "DefaultProfilePicture").Select(x => x.Value).ToString();
                        dbobj.SaveChanges();
                    }

                    dbobj.UserProfile.Add(upobj);
                    dbobj.SaveChanges();

                    return(RedirectToAction("SearchNotes", "SearchNotes"));
                }
                else
                {
                    UserProfile oldupobj = dbobj.UserProfile.Where(x => x.UserID == obj.ID).FirstOrDefault();

                    Users olduserobj = dbobj.Users.Where(x => x.ID == obj.ID).FirstOrDefault();

                    olduserobj.FirstName    = model.FirstName;
                    olduserobj.LastName     = model.LastName;
                    olduserobj.EmailID      = model.EmailID;
                    olduserobj.ModifiedDate = DateTime.Now;
                    olduserobj.ModifiedBy   = olduserobj.ID;

                    oldupobj.DOB    = model.DateOfBirth;
                    oldupobj.Gender = model.Gender;
                    oldupobj.PhoneNumberCountryCode = model.CountryCode;
                    oldupobj.PhoneNumber            = model.PhoneNumber;
                    oldupobj.AddressLine1           = model.AddressLine1;
                    oldupobj.AddressLine2           = model.AddressLine2;
                    oldupobj.City         = model.City;
                    oldupobj.State        = model.State;
                    oldupobj.ZipCode      = model.ZipCode;
                    oldupobj.Country      = model.CountryID;
                    oldupobj.University   = model.University;
                    oldupobj.College      = model.College;
                    oldupobj.ModifiedDate = DateTime.Now;
                    oldupobj.ModifiedBy   = obj.ID;

                    string path = Path.Combine(Server.MapPath("~/Members"), obj.ID.ToString());

                    //Saving Profile Picture
                    if (model.ProfilePicture != null && model.ProfilePicture.ContentLength > 0)
                    {
                        var      OldProfilePicture = Server.MapPath(oldupobj.ProfilePicture);
                        FileInfo file = new FileInfo(OldProfilePicture);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                        var ProfilePicture = DateTime.Now.ToString().Replace(':', '-').Replace(' ', '_') + Path.GetExtension(model.ProfilePicture.FileName);
                        var ImageSavePath  = Path.Combine(Server.MapPath("~/Members/" + obj.ID + "/") + "DP_" + ProfilePicture);
                        model.ProfilePicture.SaveAs(ImageSavePath);
                        oldupobj.ProfilePicture = Path.Combine(("Members/" + obj.ID + "/"), "DP_" + ProfilePicture);
                        dbobj.SaveChanges();
                    }

                    dbobj.Entry(olduserobj).State = System.Data.Entity.EntityState.Modified;
                    dbobj.Entry(oldupobj).State   = System.Data.Entity.EntityState.Modified;
                    dbobj.SaveChanges();

                    return(RedirectToAction("SearchNotes", "SearchNotes"));
                }
            }
            ViewBag.ProfilePicture = dbobj.UserProfile.Where(x => x.UserID == obj.ID).Select(x => x.ProfilePicture).FirstOrDefault();
            return(View(model));
        }
コード例 #28
0
        public ActionResult Download(int nid)
        {
            var   emailid = User.Identity.Name.ToString();
            Users obj     = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault();

            SellerNotes noteobj = dbobj.SellerNotes.Where(x => x.ID == nid).FirstOrDefault();

            Users sellerobj = dbobj.Users.Where(x => x.ID == noteobj.SellerID).FirstOrDefault();

            Transection deal = dbobj.Transection.Where(x => x.NoteID == nid && x.BuyerID == obj.ID).FirstOrDefault();

            if (obj.ID == noteobj.SellerID)     // Users own book
            {
                using (ZipFile zip = new ZipFile())
                {
                    zip.AddDirectory(Server.MapPath("~/Members/" + noteobj.SellerID + "/" + nid + "/" + "Attachment"));

                    MemoryStream output = new MemoryStream();
                    zip.Save(output);
                    return(File(output.ToArray(), "Attachment/zip", noteobj.Title + ".zip"));
                }
            }
            else
            {
                if (deal == null)                // New Transection
                {
                    if (noteobj.IsPaid == false) // Download Free Notes
                    {
                        Transection tobj = new Transection();
                        tobj.NoteID       = nid;
                        tobj.Title        = noteobj.Title;
                        tobj.Category     = noteobj.NoteCategories.Name;
                        tobj.IsPaid       = false;
                        tobj.Price        = noteobj.SellingPrice;
                        tobj.BuyerID      = obj.ID;
                        tobj.SellerID     = noteobj.SellerID;
                        tobj.IsAllowed    = true;
                        tobj.IsDownloaded = true;
                        tobj.DownloadDate = DateTime.Now;
                        tobj.Status       = noteobj.ReferenceData.Value;
                        tobj.CreatedDate  = DateTime.Now;

                        dbobj.Transection.Add(tobj);
                        dbobj.SaveChanges();

                        using (ZipFile zip = new ZipFile())
                        {
                            zip.AddDirectory(Server.MapPath("~/Members/" + noteobj.SellerID + "/" + nid + "/" + "Attachment"));

                            MemoryStream output = new MemoryStream();
                            zip.Save(output);
                            return(File(output.ToArray(), "Attachment/zip", noteobj.Title + ".zip"));
                        }
                    }
                    else    // Download Paid Notes
                    {
                        Transection tobj = new Transection();
                        tobj.NoteID       = nid;
                        tobj.Title        = noteobj.Title;
                        tobj.Category     = noteobj.NoteCategories.Name;
                        tobj.IsPaid       = true;
                        tobj.Price        = noteobj.SellingPrice;
                        tobj.BuyerID      = obj.ID;
                        tobj.SellerID     = noteobj.SellerID;
                        tobj.IsAllowed    = false;
                        tobj.IsDownloaded = false;
                        tobj.DownloadDate = null;
                        tobj.Status       = noteobj.ReferenceData.Value;
                        tobj.CreatedDate  = DateTime.Now;

                        dbobj.Transection.Add(tobj);
                        dbobj.SaveChanges();
                        NotifySeller(sellerobj.EmailID, obj.FirstName, sellerobj.FirstName);
                        //return RedirectToAction("NoteDetails", new { nid });
                        ViewBag.CurrentUserName = obj.FirstName;
                        return(RedirectToAction("NoteDetails", new { nid }));
                        //return PartialView("ThanksPopup", noteobj);
                    }
                }
                else                             // Old Transection Available
                {
                    if (noteobj.IsPaid == false) // Download Free Notes
                    {
                        using (ZipFile zip = new ZipFile())
                        {
                            zip.AddDirectory(Server.MapPath("~/Members/" + noteobj.SellerID + "/" + nid + "/" + "Attachment"));

                            MemoryStream output = new MemoryStream();
                            zip.Save(output);
                            return(File(output.ToArray(), "Attachment/zip", noteobj.Title + ".zip"));
                        }
                    }
                    else    // Download Paid Notes
                    {
                        if ((bool)deal.IsAllowed)
                        {
                            deal.IsDownloaded = true;
                            deal.DownloadDate = DateTime.Now;

                            dbobj.Entry(deal).State = System.Data.Entity.EntityState.Modified;
                            dbobj.SaveChanges();

                            using (ZipFile zip = new ZipFile())
                            {
                                zip.AddDirectory(Server.MapPath("~/Members/" + noteobj.SellerID + "/" + nid + "/" + "Attachment"));

                                MemoryStream output = new MemoryStream();
                                zip.Save(output);
                                return(File(output.ToArray(), "Attachment/zip", noteobj.Title + ".zip"));
                            }
                        }
                        else
                        {
                            return(RedirectToAction("NoteDetails", nid));
                        }
                    }
                }
            }
        }