示例#1
0
        //GET: Details/{id}
        public ActionResult Details(int id)
        {
            NoteService service = CreateNoteService();
            NoteDetail  model   = service.GetNoteById(id);

            return(View(model));
        }
示例#2
0
        public IHttpActionResult Get(int id)
        {
            NoteService noteService = CreateNoteService();
            //get the note by id from note service
            NoteDetail note = noteService.GetNoteById(id);

            return(Ok(note));
        }
示例#3
0
 public ActionResult NoteDetail(int id, Notedetailmodal notedetailmodal)
 {
     projectEntities1 db   = new projectEntities1();
     NoteDetail       data = db.NoteDetails.Where(u => u.Id == id).FirstOrDefault();
     {
         return(View(data));
     }
 }
示例#4
0
    public async Task Handle(NoteCreatedEvent notification, CancellationToken cancellationToken)
    {
        var note = new NoteDetail();

        note.When(notification);

        await _readModelRepository.InsertAsync(note);

        await InsertHistoryAsync(note, notification.OccurrenceTime);
    }
示例#5
0
        //GET: Edit/{id}
        public ActionResult Edit(int id)
        {
            NoteService service = CreateNoteService();
            NoteDetail  detail  = service.GetNoteById(id);
            NoteEdit    model   = new NoteEdit {
                NoteId = detail.NoteId, Title = detail.Title, Content = detail.Content
            };

            return(View(model));
        }
示例#6
0
 public ActionResult Approve(int id)
 {
     projectEntities1 db   = new projectEntities1();
     NoteDetail       data = db.NoteDetails.Where(u => u.Id == id).FirstOrDefault();
     {
         data.Status = "Published";
         db.SaveChanges();
         return(View());
     }
 }
示例#7
0
        public override void Arrange()
        {
            base.Arrange();

            _noteDetail = new NoteDetail
            {
                NoteId = Id
            };
            NoteService.GetNoteByIdResult = _noteDetail;
        }
示例#8
0
        public override void Arrange()
        {
            base.Arrange();

            _noteDetail = new NoteDetail
            {
                NoteId  = Id,
                Content = "content",
                Title   = "title"
            };
            NoteService.GetNoteByIdResult = _noteDetail;
        }
示例#9
0
        public ActionResult EditNotes(string noteid, AddNotesModel notesModel, HttpPostedFileBase dp, HttpPostedFileBase uploadnote, HttpPostedFileBase notepreview)
        {
            if (Session["Id"] != null)
            {
                int id = Convert.ToInt32(Session["Id"].ToString());
                using (projectEntities1 db = new projectEntities1())
                {
                    MembersData usr = db.MembersDatas.Where(u => u.Id == id).FirstOrDefault();
                    {
                        NoteDetail notes = db.NoteDetails.Where(u => u.NoteTitle == noteid).FirstOrDefault();
                        {
                            notes.Status = "Inreview";

                            string fileName = Path.GetFileName(dp.FileName);

                            notesModel.dppath = "~/images/" + fileName;
                            fileName          = Path.Combine(Server.MapPath("~/images/"), fileName);
                            dp.SaveAs(fileName);



                            string fileName1 = Path.GetFileName(uploadnote.FileName);


                            notesModel.uploadpath = "~/images/" + fileName1;
                            fileName = Path.Combine(Server.MapPath("~/images/"), fileName1);
                            uploadnote.SaveAs(fileName);


                            string fileName2 = Path.GetFileName(notepreview.FileName);

                            notesModel.notepath = "~/images/" + fileName2;
                            fileName            = Path.Combine(Server.MapPath("~/images/"), fileName2);
                            notepreview.SaveAs(fileName);

                            notes.ApprovedDate = DateTime.Now;
                            notes.DisplayPic   = notesModel.dppath;
                            notes.Preview      = notesModel.notepath;
                            notes.note         = notesModel.uploadpath;
                            db.SaveChanges();
                            return(RedirectToAction("SearchNotes", "NoteDetails"));
                        }
                    }
                }
            }
            else

            {
                return(View());
            }
        }
示例#10
0
      public ActionResult Delete(int id)
      {
          var service = CreateNoteService();
          var detail  = service.GetNoteById(id);
          var model   =
              new NoteDetail
          {
              NoteId  = detail.NoteId,
              Title   = detail.Title,
              Content = detail.Content
          };

          return(View(model));
      }
示例#11
0
        public ActionResult SearchNotes(string searchn, string country, string type, string category, string university, string course)
        {
            NoteDetail       nm = new NoteDetail();
            Notedetailmodal  sn = new Notedetailmodal();
            projectEntities1 db = new projectEntities1();

            ViewData["Category"]   = db.Categories.ToList <Category>();
            ViewData["Type"]       = db.Types.ToList();
            ViewData["Country"]    = db.Countries.ToList();
            ViewData["Rate"]       = db.Ratings.ToList();
            ViewData["Course"]     = db.NoteDetails.ToList();
            ViewData["University"] = db.NoteDetails.ToList();

            List <NoteDetail> notes = db.NoteDetails.ToList();

            if (!string.IsNullOrEmpty(searchn))
            {
                notes = notes.Where(e => e.NoteTitle.ToLower().Contains(searchn.ToLower())).ToList();
            }
            if (country != "Select country" && !string.IsNullOrEmpty(country))
            {
                notes = notes.Where(e => e.Country != null && e.Country.ToLower().Contains(country.ToLower())).ToList();
            }
            if (type != "Select Type" && !string.IsNullOrEmpty(type))
            {
                notes = notes.Where(e => e.Type != null && e.Type.ToLower().Contains(type.ToLower())).ToList();
            }

            if (category != "Select category" && !string.IsNullOrEmpty(category))
            {
                notes = notes.Where(e => e.Category != null && e.Category.ToLower().Contains(category.ToLower())).ToList();
            }

            if (university != "Select University" && !string.IsNullOrEmpty(university))
            {
                notes = notes.Where(e => e.University != null && e.University.ToLower().Contains(university.ToLower())).ToList();
            }

            if (course != "Select Course" && !string.IsNullOrEmpty(course))
            {
                notes = notes.Where(e => e.Course != null && e.Course.ToLower().Contains(course.ToLower())).ToList();
            }



            return(View(notes));
        }
示例#12
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            //Button Name   : btnSearch_Click
            //Purpose       : calls for method GetNoteDetail() to check if note exists
            //Input         : noteId
            //Output        : note
            bool hasValues = HasValues();

            if (hasValues)
            {
                bool isNum = IsNumber();
                if (isNum)
                {
                    bool isStNum = IsStudentNum();
                    if (isNum)
                    {
                        string noteId = txtNoteId.Text;
                        noteDetail = myNoteProxy.GetNoteDetail(noteId);
                        if (noteDetail != null)
                        {
                            txtNoteContent.Text = noteDetail.noteContent.ToString();
                            txtStudentId.Text   = noteDetail.studentId.ToString();
                        }
                        else
                        {
                            MessageBox.Show("note does not exist", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("make sure note ID is a number!", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    MessageBox.Show("make sure note ID is a number!", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show("Please enter Id.", "INFORMATION", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            txtNoteContent.IsEnabled = true;
            txtNoteId.IsEnabled      = false;
            txtStudentId.IsEnabled   = false;
        }
示例#13
0
        public ActionResult Rates(int noteid, RatesModel rt)
        {
            Rating r = new Rating();

            using (projectEntities1 db = new projectEntities1())
            {
                NoteDetail nm = db.NoteDetails.Where(u => u.Id == noteid).FirstOrDefault();
                {
                    r.Date        = DateTime.Now;
                    r.Description = rt.comment;
                    r.BuyerId     = 10;
                    r.NoteId      = noteid;
                    r.Rate        = Convert.ToInt32(Request.Form["rate"]);
                    db.Ratings.Add(r);
                    db.SaveChanges();
                    return(View());
                }
            }
        }
示例#14
0
 public ActionResult DeleteNotes(int noteid)
 {
     if (Session["Id"] != null)
     {
         int id = Convert.ToInt32(Session["Id"].ToString());
         using (projectEntities1 db = new projectEntities1())
         {
             MembersData usr = db.MembersDatas.Where(u => u.Id == id).FirstOrDefault();
             {
                 NoteDetail nd = db.NoteDetails.Where(u => u.Id == noteid).FirstOrDefault();
                 {
                     db.NoteDetails.Remove(nd);
                     return(View());
                 }
             }
         }
     }
     return(View());
 }
示例#15
0
        public ActionResult EditNotes(int noteid, AddNotesModel notesModel)
        {
            if (Session["Id"] != null)
            {
                int id = Convert.ToInt32(Session["Id"].ToString());
                using (projectEntities1 db = new projectEntities1())
                {
                    MembersData usr = db.MembersDatas.Where(u => u.Id == id).FirstOrDefault();
                    {
                        NoteDetail nd = db.NoteDetails.Where(u => u.Id == noteid).FirstOrDefault();
                        {
                            ViewData["Category"] = db.Categories.ToList <Category>();
                            ViewData["Type"]     = db.Types.ToList();
                            ViewData["Country"]  = db.Countries.ToList();



                            notesModel.country    = nd.Country;
                            notesModel.category   = nd.Category;
                            notesModel.coursecode = nd.CourseCode;
                            notesModel.coursename = nd.Course;
                            notesModel.Disc       = nd.Description;

                            notesModel.instituename = nd.University;
                            notesModel.Noofpage     = nd.NoOfPages;

                            notesModel.price     = nd.SellPrice;
                            notesModel.professor = nd.Professor;
                            notesModel.Title     = nd.NoteTitle;
                            notesModel.type      = nd.Type;

                            return(View(notesModel));
                        }
                    }
                }
            }
            else
            {
                return(View());
            }
        }
示例#16
0
    private async Task InsertHistoryAsync(NoteDetail note, DateTimeOffset creationTime, string comment = "")
    {
        if (note.Status == NoteStatus.Draft)
        {
            return;
        }

        var noteHistory = new NoteHistory
        {
            Id           = Guid.NewGuid(),
            NoteId       = note.Id,
            Title        = note.Title,
            Content      = note.Content,
            Version      = note.Version,
            CreationTime = creationTime,
            CloneFormId  = note.CloneFormId,
            Comment      = comment
        };

        await _readModelRepository.InsertAsync(noteHistory);
    }
        public ActionResult EditNotes(int id)
        {
            Context.Users    user        = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();
            NoteDetail       note        = dobj.NoteDetail.Where(x => x.ID == id && x.IsActive == true && x.SellerID == user.ID).FirstOrDefault();
            NotesAttachments attachement = dobj.NotesAttachments.Where(x => x.NoteID == id).FirstOrDefault();

            if (note != null)
            {
                EditNotes viewModel = new EditNotes
                {
                    ID             = note.ID,
                    NoteID         = note.ID,
                    Title          = note.Title,
                    Category       = note.Category,
                    Picture        = note.DisplayPicture,
                    Note           = attachement.FileName,
                    NumberofPages  = note.NumberofPages,
                    Description    = note.Description,
                    NoteType       = note.NoteType,
                    UniversityName = note.UniversityName,
                    Course         = note.Course,
                    CourseCode     = note.CourseCode,
                    Country        = note.Country,
                    Professor      = note.Professor,
                    IsPaid         = note.IsPaid,
                    SellingPrice   = note.SellingPrice,
                    Preview        = note.NotesPreview,

                    NoteCategoryList = dobj.NoteCategories.Where(x => x.IsActive == true).ToList(),
                    NoteTypeList     = dobj.NoteTypes.Where(x => x.IsActive == true).ToList(),
                    CountryList      = dobj.Countries.Where(x => x.IsActive == true).ToList(),
                };

                return(View(viewModel));
            }
            else
            {
                return(HttpNotFound());
            }
        }
        public ActionResult DeleteDraft(int id)
        {
            NoteDetail note = dobj.NoteDetail.Where(x => x.ID == id && x.IsActive == true).FirstOrDefault();

            if (note == null)
            {
                return(HttpNotFound());
            }

            IEnumerable <NotesAttachments> noteattachement = dobj.NotesAttachments.Where(x => x.NoteID == id && x.IsActive == true).ToList();

            if (noteattachement.Count() == 0)
            {
                return(HttpNotFound());
            }

            string notefolderpath           = Server.MapPath("~/Members/" + note.SellerID + "/" + note.ID);
            string noteattachmentfolderpath = Server.MapPath("~/Members/" + note.SellerID + "/" + note.ID + "/Attachements");

            DirectoryInfo notefolder            = new DirectoryInfo(notefolderpath);
            DirectoryInfo attachementnotefolder = new DirectoryInfo(noteattachmentfolderpath);

            EmptyFolder(attachementnotefolder);
            EmptyFolder(notefolder);

            Directory.Delete(notefolderpath);

            dobj.NoteDetail.Remove(note);

            foreach (var item in noteattachement)
            {
                NotesAttachments attachement = dobj.NotesAttachments.Where(x => x.ID == item.ID).FirstOrDefault();
                dobj.NotesAttachments.Remove(attachement);
            }
            dobj.SaveChanges();

            return(RedirectToAction("Dashboard", "SellNotes"));
        }
示例#19
0
        public ActionResult aprovereq(int sellerid)
        {
            projectEntities1 db = new projectEntities1();



            Buyer by = db.Buyers.Where(u => u.MemberId == sellerid).FirstOrDefault();

            {
                by.IsActive     = true;
                by.ApprovedDate = DateTime.Now;
                NoteDetail nm = db.NoteDetails.Where(u => u.Id == by.BookId).FirstOrDefault();
                {
                    Seller usr = db.Sellers.Where(u => u.ModifiedBy == by.MemberId).FirstOrDefault();
                    {
                        usr.IsActive     = true;
                        usr.ApprovedDate = DateTime.Now;

                        db.SaveChanges();
                    }
                }
            }
            return(RedirectToAction("Registration", "Auth"));
        }
示例#20
0
        public ActionResult DownloadNotes(int noteid)
        {
            if (Session["Id"] != null)
            {
                int id1 = Convert.ToInt32(Session["Id"].ToString());
                using (projectEntities1 db = new projectEntities1())
                {
                    MembersData usr = db.MembersDatas.Where(u => u.Id == id1).FirstOrDefault();
                    {
                        NoteDetail nm = db.NoteDetails.Where(u => u.Id == noteid).FirstOrDefault();

                        if (nm.SellFor == true)
                        {
                            Seller sl = new Seller();
                            sl.MemberId = nm.OwnerId;
                            Buyer by = new Buyer();
                            by.MemberId = id1;

                            var         fromemail = new MailAddress("*****@*****.**");
                            var         toemail   = new MailAddress(usr.EmailId);
                            MailMessage mm        = new MailMessage("*****@*****.**", usr.EmailId);
                            mm.Subject    = "Check" + usr.FirstName + " wants to purchase your notes  ";
                            mm.IsBodyHtml = true;
                            mm.Body       = "Hello" + usr.LastName + "," + "<div>We would like to inform you that" + usr.FirstName + " wants to purchase your notes. Please see Buyer Requests tab and allow download access to Buyer if you have received the payment from him." + "<div>Regards,<div>Notes Marketplace ";


                            SmtpClient smtp = new SmtpClient();
                            smtp.Host           = "smtp.gmail.com";
                            smtp.Port           = 587;
                            smtp.EnableSsl      = true;
                            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

                            smtp.UseDefaultCredentials = false;
                            smtp.Credentials           = new NetworkCredential(fromemail.Address, "Note@tatva");

                            smtp.Send(mm);

                            by.BookId       = noteid;
                            by.ApprovedDate = null;
                            by.ReqDate      = DateTime.Now;
                            by.IsActive     = false;
                            db.Buyers.Add(by);
                            sl.BookId       = noteid;
                            sl.IsActive     = false;
                            sl.MemberId     = nm.OwnerId;
                            sl.ModifiedBy   = id1;
                            sl.ReqDate      = DateTime.Now;
                            sl.ApprovedDate = DateTime.Now;
                            db.Sellers.Add(sl);
                            db.SaveChanges();

                            return(RedirectToAction("MyDownload", "NoteDetails"));
                        }

                        else
                        {
                            Seller sl = new Seller();
                            Buyer  by = new Buyer();
                            by.MemberId     = id1;
                            by.BookId       = noteid;
                            by.ApprovedDate = DateTime.Now;
                            by.ReqDate      = DateTime.Now;
                            by.IsActive     = true;
                            db.Buyers.Add(by);
                            sl.BookId       = noteid;
                            sl.IsActive     = true;
                            sl.MemberId     = nm.OwnerId;
                            sl.ModifiedBy   = id1;
                            sl.ReqDate      = DateTime.Now;
                            sl.ApprovedDate = DateTime.Now;
                            db.Sellers.Add(sl);
                            db.SaveChanges();
                            TempData["Success"] = "Download sucsessfully";
                            return(RedirectToAction("MyDownload", "NoteDetails"));
                        }
                    }
                }
            }
            else
            {
                TempData["Success"] = "Please sign in/register to download this note.";
                return(RedirectToAction("Registration", "Auth"));
            }
        }
示例#21
0
        /// <summary>
        /// Open pane based on pane name
        /// </summary>
        /// <typeparam name="TMessage">Message</typeparam>
        /// <param name="paneName">Pane name</param>
        /// <param name="msg">Message</param>
        protected override void AddPane <TMessage>(string paneName, TMessage msg)
        {
            string header = "";
            object content;

            switch (paneName)
            {
            case addPivotItemName:

                content = new NoteAdd();

                if (msg.GetType() == typeof(ItemAddNewMsg))
                {
                    header = "Add Note";
                }
                else
                {
                    header = "Edit Note";
                }

                break;

            case detailPivotItemName:

                content = new NoteDetail();

                header = "Note Detail";
                break;

            default:
                throw new NotImplementedException();
            }

            try
            {
                if (PivotPanes.FirstOrDefault(x => x.Name == paneName) == null)
                {
                    PivotPanes.Insert(0, new PivotItem()
                    {
                        Name    = paneName,
                        Header  = header,
                        Margin  = new Thickness(0),
                        Content = content
                    });
                }
                else
                {
                    PivotPanes.FirstOrDefault(x => x.Name == paneName).Header  = header;
                    PivotPanes.FirstOrDefault(x => x.Name == paneName).Content = content;
                }
            }
            catch (Exception)
            {
                PivotPanes.Clear();
                PivotPanes.Insert(0, new PivotItem()
                {
                    Name    = paneName,
                    Header  = header,
                    Content = content
                });
            }
            finally
            {
                if (PivotPanes.FirstOrDefault(x => x.Name == paneName) != null)
                {
                    //pivotPanes = PivotPanes;
                    RaisePropertyChanged(nameof(PivotPanes));

                    PaneVisibility = true;

                    double MinNormalWidth = (double)Application.Current.Resources["NormalMinWidth"];
                    if (MinNormalWidth > ApplicationView.GetForCurrentView().VisibleBounds.Width)
                    {
                        MasterFrame = new GridLength(0);
                    }

                    Messenger.Send(msg);
                }
            }
        }
        public ActionResult CloneNote(int noteid)
        {
            // logged in user
            var user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();

            //get id of rejected notes
            var rejectednote = dobj.NoteDetail.Find(noteid);

            // creare clone of note
            NoteDetail clonenote = new NoteDetail();

            clonenote.SellerID       = rejectednote.SellerID;
            clonenote.Status         = 6;
            clonenote.Title          = rejectednote.Title;
            clonenote.Category       = rejectednote.Category;
            clonenote.NoteType       = rejectednote.NoteType;
            clonenote.NumberofPages  = rejectednote.NumberofPages;
            clonenote.Description    = rejectednote.Description;
            clonenote.UniversityName = rejectednote.UniversityName;
            clonenote.Country        = rejectednote.Country;
            clonenote.Course         = rejectednote.Course;
            clonenote.CourseCode     = rejectednote.CourseCode;
            clonenote.Professor      = rejectednote.Professor;
            clonenote.IsPaid         = rejectednote.IsPaid;
            clonenote.SellingPrice   = rejectednote.SellingPrice;
            clonenote.CreatedBy      = user.ID;
            clonenote.CreatedDate    = DateTime.Now;
            clonenote.IsActive       = true;

            // save note in database
            dobj.NoteDetail.Add(clonenote);
            dobj.SaveChanges();

            // get clonenote
            clonenote = dobj.NoteDetail.Find(clonenote.ID);

            // if display picture is not null then copy file from rejected note's folder to clone note's new folder
            if (rejectednote.DisplayPicture != null)
            {
                var rejectednotefilepath = Server.MapPath(rejectednote.DisplayPicture);
                var clonenotefilepath    = "~/Members/" + user.ID + "/" + clonenote.ID + "/";

                var filepath = Path.Combine(Server.MapPath(clonenotefilepath));

                FileInfo file = new FileInfo(rejectednotefilepath);

                Directory.CreateDirectory(filepath);
                if (file.Exists)
                {
                    System.IO.File.Copy(rejectednotefilepath, Path.Combine(filepath, Path.GetFileName(rejectednotefilepath)));
                }

                clonenote.DisplayPicture = Path.Combine(clonenotefilepath, Path.GetFileName(rejectednotefilepath));
                dobj.SaveChanges();
            }

            // if note preview is not null then copy file from rejected note's folder to clone note's new folder
            if (rejectednote.NotesPreview != null)
            {
                var rejectednotefilepath = Server.MapPath(rejectednote.NotesPreview);
                var clonenotefilepath    = "~/Members/" + user.ID + "/" + clonenote.ID + "/";

                var filepath = Path.Combine(Server.MapPath(clonenotefilepath));

                FileInfo file = new FileInfo(rejectednotefilepath);

                Directory.CreateDirectory(filepath);

                if (file.Exists)
                {
                    System.IO.File.Copy(rejectednotefilepath, Path.Combine(filepath, Path.GetFileName(rejectednotefilepath)));
                }

                clonenote.NotesPreview = Path.Combine(clonenotefilepath, Path.GetFileName(rejectednotefilepath));
                dobj.SaveChanges();
            }

            // attachment path of rejected note and clone note
            var rejectednoteattachement = Server.MapPath("~/Members/" + user.ID + "/" + rejectednote.ID + "/Attachements/");
            var clonenoteattachement    = "~/Members/" + user.ID + "/" + clonenote.ID + "/Attachements/";

            var attachementfilepath = Path.Combine(Server.MapPath(clonenoteattachement));

            // create directory for attachement folder
            Directory.CreateDirectory(attachementfilepath);

            // get attachements files from rejected note and copy to clone note
            foreach (var files in Directory.GetFiles(rejectednoteattachement))
            {
                FileInfo file = new FileInfo(files);

                if (file.Exists)
                {
                    System.IO.File.Copy(file.ToString(), Path.Combine(attachementfilepath, Path.GetFileName(file.ToString())));
                }

                // save attachment in database
                NotesAttachments attachement = new NotesAttachments();
                attachement.NoteID      = clonenote.ID;
                attachement.FileName    = Path.GetFileName(file.ToString());
                attachement.FilePath    = clonenoteattachement;
                attachement.CreatedDate = DateTime.Now;
                attachement.CreatedBy   = user.ID;
                attachement.IsActive    = true;

                dobj.NotesAttachments.Add(attachement);
                dobj.SaveChanges();
            }
            return(RedirectToAction("Dashboard", "SellNotes"));
        }
示例#23
0
        public ActionResult AddNotes(AddNotesModel notesModel, HttpPostedFileBase dp, HttpPostedFileBase uploadnote, HttpPostedFileBase notepreview)
        {
            if (Session["Id"] != null)
            {
                int id = Convert.ToInt32(Session["Id"].ToString());
                using (projectEntities1 db = new projectEntities1())
                {
                    MembersData usr = db.MembersDatas.Where(u => u.Id == id).FirstOrDefault();
                    {
                        //projectEntities1 db = new projectEntities1();
                        NoteDetail notes = new NoteDetail();

                        ViewData["Category"] = db.Categories.ToList <Category>();
                        ViewData["Type"]     = db.Types.ToList();
                        ViewData["Country"]  = db.Countries.ToList();
                        notes.Category       = notesModel.category;
                        notes.Type           = notesModel.type;
                        notes.Country        = notesModel.country;
                        notes.OwnerId        = id;
                        notes.SellFor        = false;
                        notes.ReqDate        = DateTime.Now;
                        notes.ApprovedDate   = DateTime.Now;
                        notes.IsActive       = true;
                        notes.NoteTitle      = notesModel.Title;
                        notes.NoOfPages      = notesModel.Noofpage;
                        notes.Description    = notesModel.Disc;
                        notes.University     = notesModel.instituename;
                        notes.Course         = notesModel.coursename;
                        notes.CourseCode     = notesModel.coursecode;
                        notes.Professor      = notesModel.professor;
                        notes.SellPrice      = notesModel.price;
                        notes.Status         = "Drafted";

                        string fileName = Path.GetFileName(dp.FileName);

                        notesModel.dppath = "~/images/" + fileName;
                        fileName          = Path.Combine(Server.MapPath("~/images/"), fileName);
                        dp.SaveAs(fileName);

                        db.NoteDetails.Add(notes);


                        string fileName1 = Path.GetFileName(uploadnote.FileName);


                        notesModel.uploadpath = "~/images/" + fileName1;
                        fileName = Path.Combine(Server.MapPath("~/images/"), fileName1);
                        uploadnote.SaveAs(fileName);

                        db.NoteDetails.Add(notes);

                        string fileName2 = Path.GetFileName(notepreview.FileName);

                        notesModel.notepath = "~/images/" + fileName2;
                        fileName            = Path.Combine(Server.MapPath("~/images/"), fileName2);
                        notepreview.SaveAs(fileName);

                        db.NoteDetails.Add(notes);

                        notes.DisplayPic = notesModel.dppath;
                        notes.Preview    = notesModel.notepath;
                        notes.note       = notesModel.uploadpath;
                        db.SaveChanges();
                        return(View());
                    }
                }
            }
            else
            {
                return(View());
            }
        }
        public ActionResult AddNotes(AddNotes add, string command)
        {
            if (add.UploadNotes[0] == null)
            {
                ModelState.AddModelError("UploadNotes", "This field is required");
                add.NoteCategoryList = dobj.NoteCategories.Where(x => x.IsActive == true).ToList();
                add.NoteTypeList     = dobj.NoteTypes.Where(x => x.IsActive == true).ToList();
                add.CountryList      = dobj.Countries.Where(x => x.IsActive == true).ToList();
                return(View(add));
            }

            if (add.IsPaid == true && add.NotesPreview == null)
            {
                ModelState.AddModelError("NotesPreview", "This field is required if selling type is paid");
                add.NoteCategoryList = dobj.NoteCategories.Where(x => x.IsActive == true).ToList();
                add.NoteTypeList     = dobj.NoteTypes.Where(x => x.IsActive == true).ToList();
                add.CountryList      = dobj.Countries.Where(x => x.IsActive == true).ToList();
                return(View(add));
            }
            foreach (HttpPostedFileBase file in add.UploadNotes)
            {
                if (!System.IO.Path.GetExtension(file.FileName).Equals(".pdf"))
                {
                    ModelState.AddModelError("UploadNotes", "Only PDF Format is allowed");
                    add.NoteCategoryList = dobj.NoteCategories.Where(x => x.IsActive == true).ToList();
                    add.NoteTypeList     = dobj.NoteTypes.Where(x => x.IsActive == true).ToList();
                    add.CountryList      = dobj.Countries.Where(x => x.IsActive == true).ToList();
                    return(View(add));
                }
            }
            if (ModelState.IsValid)
            {
                NoteDetail sellnote = new NoteDetail();

                Context.Users user = dobj.Users.FirstOrDefault(x => x.EmailID == User.Identity.Name);

                sellnote.SellerID       = user.ID;
                sellnote.Title          = add.Title;
                sellnote.Status         = command == "Save" ? 6 : 7;
                sellnote.Category       = add.Category;
                sellnote.NoteType       = add.NoteType;
                sellnote.NumberofPages  = add.NumberofPages;
                sellnote.Description    = add.Description;
                sellnote.UniversityName = add.UniversityName;
                sellnote.Country        = add.Country;
                sellnote.Course         = add.Course;
                sellnote.CourseCode     = add.CourseCode;
                sellnote.Professor      = add.Professor;
                sellnote.IsPaid         = add.IsPaid;
                if (sellnote.IsPaid)
                {
                    sellnote.SellingPrice = add.SellingPrice;
                }
                else
                {
                    sellnote.SellingPrice = 0;
                }

                if (sellnote.Status == 7)
                {
                    string sellername = user.FirstName + " " + user.LastName;
                    PublishNoteRequestmail(sellnote.Title, sellername);
                }


                sellnote.CreatedDate = DateTime.Now;
                sellnote.CreatedBy   = user.ID;
                sellnote.IsActive    = true;

                dobj.NoteDetail.Add(sellnote);
                dobj.SaveChanges();

                sellnote = dobj.NoteDetail.Find(sellnote.ID);
                if (add.DisplayPicture != null)
                {
                    string displaypicturefilename = System.IO.Path.GetFileName(add.DisplayPicture.FileName);
                    string displaypicturepath     = "~/Members/" + user.ID + "/" + sellnote.ID + "/";
                    NewDirectory(displaypicturepath);
                    string displaypicturefilepath = Path.Combine(Server.MapPath(displaypicturepath), displaypicturefilename);
                    sellnote.DisplayPicture = displaypicturepath + displaypicturefilename;
                    add.DisplayPicture.SaveAs(displaypicturefilepath);
                }

                if (add.NotesPreview != null)
                {
                    string notespreviewfilename = System.IO.Path.GetFileName(add.NotesPreview.FileName);
                    string notespreviewpath     = "~/Members/" + user.ID + "/" + sellnote.ID + "/";
                    NewDirectory(notespreviewpath);
                    string notespreviewfilepath = Path.Combine(Server.MapPath(notespreviewpath), notespreviewfilename);
                    sellnote.NotesPreview = notespreviewpath + notespreviewfilename;
                    add.NotesPreview.SaveAs(notespreviewfilepath);
                }

                dobj.NoteDetail.Attach(sellnote);
                dobj.Entry(sellnote).Property(x => x.DisplayPicture).IsModified = true;
                dobj.Entry(sellnote).Property(x => x.NotesPreview).IsModified   = true;
                dobj.SaveChanges();

                foreach (HttpPostedFileBase file in add.UploadNotes)
                {
                    if (file != null)
                    {
                        string notesattachementfilename = System.IO.Path.GetFileName(file.FileName);
                        string notesattachementpath     = "~/Members/" + user.ID + "/" + sellnote.ID + "/Attachements/";
                        NewDirectory(notesattachementpath);
                        string notesattachementfilepath = Path.Combine(Server.MapPath(notesattachementpath), notesattachementfilename);
                        file.SaveAs(notesattachementfilepath);

                        NotesAttachments notesattachements = new NotesAttachments
                        {
                            NoteID      = sellnote.ID,
                            FileName    = notesattachementfilename,
                            FilePath    = notesattachementpath,
                            CreatedDate = DateTime.Now,
                            CreatedBy   = user.ID,
                            IsActive    = true
                        };

                        dobj.NotesAttachments.Add(notesattachements);
                        dobj.SaveChanges();
                    }
                }

                return(RedirectToAction("Dashboard", "SellNotes"));
            }
            else
            {
                AddNotes viewModel = new AddNotes
                {
                    NoteCategoryList = dobj.NoteCategories.Where(x => x.IsActive == true).ToList(),
                    NoteTypeList     = dobj.NoteTypes.Where(x => x.IsActive == true).ToList(),
                    CountryList      = dobj.Countries.Where(x => x.IsActive == true).ToList()
                };

                return(View(viewModel));
            }
        }