public void UnpublishNoteTemplate(string remark, Context.Users seller, Context.NoteDetail note) { var email = dobj.SystemConfiguration.Select(x => x.EmailID1).FirstOrDefault(); var fromEmail = new MailAddress(email); var toEmail = new MailAddress(seller.EmailID); var fromEmailPassword = "******"; //replace with original password string subject = "Sorry! We need to remove your notes from our portal."; string body = "Hello " + seller.FirstName + " " + seller.LastName + "," + "<br/><br/>We want to inform you that,your note " + note.Title + " has been removed from the portal." + "<br/>Please find our remarks as below.<br/>" + "<br/><br/>Regards,<br/>Notes Marketplace"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(fromEmail.Address, fromEmailPassword) }; using (var message = new MailMessage(fromEmail, toEmail) { Subject = subject, Body = body, IsBodyHtml = true }) smtp.Send(message); }
public ActionResult Verify(string code) { Context.Users obj = dbobj.Users.Where(x => x.SecretCode.ToString() == code).FirstOrDefault(); obj.IsEmailVerified = true; dbobj.SaveChanges(); return(RedirectToAction("Login")); }
public ActionResult SignUp(Models.Users model) { if (ModelState.IsValid) { var isExist = IsEmailExist(model.EmailID); if (isExist) { ModelState.AddModelError("EmailID", "Email already exist"); return(View(model)); } Context.Users obj = new Context.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 = true; obj.CreatedDate = DateTime.Now; obj.SecretCode = Guid.NewGuid(); dbobj.Users.Add(obj); dbobj.SaveChanges(); SendVerificationLinkEmail(model.EmailID, model.FirstName, obj.SecretCode.ToString()); TempData["Success"] = "Your account has been created."; } ModelState.Clear(); return(RedirectToAction("SignUp")); }
public ActionResult ChangePassword(Models.ChangePassword model) { var emailid = User.Identity.Name.ToString(); Context.Users obj = dbobj.Users.Where(x => x.EmailID == emailid).FirstOrDefault(); if (ModelState.IsValid) { if (string.Compare(model.OldPassword, obj.Password) == 0) { obj.Password = model.NewPassword; obj.ModifiedDate = DateTime.Now; dbobj.Entry(obj).State = System.Data.Entity.EntityState.Modified; dbobj.SaveChanges(); FormsAuthentication.SignOut(); return(RedirectToAction("Login")); } else { ModelState.AddModelError("OldPassword", "OldPassword Is Incorrect"); } } return(View()); }
public ActionResult Dashboard(string search1, string search2, string sort1, string sort2, int?page1, int?page2) { ViewBag.SellNotes = "active"; ViewBag.Sort1 = sort1; ViewBag.Sort2 = sort2; ViewBag.Search1 = search1; ViewBag.Search2 = search2; Dashboard dashboard = new Dashboard(); Context.Users user = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault(); dashboard.NumberOfSoldNotes = dobj.Downloads.Where(x => x.Seller == user.ID && x.IsSellerHasAllowedDownload == true && x.AttachmentPath != null).Count(); dashboard.MoneyEarned = dobj.Downloads.Where(x => x.Seller == user.ID && x.IsSellerHasAllowedDownload == true && x.AttachmentPath != null).Select(x => x.PurchasedPrice).Sum(); dashboard.MyDownloads = dobj.Downloads.Where(x => x.Downloader == user.ID && x.IsSellerHasAllowedDownload == true && x.AttachmentPath != null).Count(); dashboard.MyRejectedNotes = dobj.NoteDetail.Where(x => x.SellerID == user.ID && x.Status == 10 && x.IsActive == true).Count(); dashboard.BuyerRequest = dobj.Downloads.Where(x => x.Seller == user.ID && x.IsSellerHasAllowedDownload == false && x.AttachmentPath == null).Count(); IEnumerable <NoteDetail> inprogress; IEnumerable <NoteDetail> published; if (string.IsNullOrEmpty(search1)) { inprogress = dobj.NoteDetail.Where(x => x.SellerID == user.ID && (x.Status == 6 || x.Status == 7 || x.Status == 8)); } else { inprogress = dobj.NoteDetail.Where(x => x.SellerID == user.ID && (x.Status == 6 || x.Status == 7 || x.Status == 8) && (x.Title.ToLower().Contains(search1) || x.NoteCategories.Name.ToLower().Contains(search1) || x.ReferenceData.Value.ToLower().Contains(search1)) ); } if (string.IsNullOrEmpty(search2)) { published = dobj.NoteDetail.Where(x => x.SellerID == user.ID && x.Status == 9); } else { search2 = search2.ToLower(); published = dobj.NoteDetail.Where(x => x.SellerID == user.ID && x.Status == 9 && (x.Title.ToLower().Contains(search2) || x.NoteCategories.Name.ToLower().Contains(search2) || x.SellingPrice.ToString().ToLower().Contains(search2)) ); } inprogress = SortTableInProgressNote(sort1, inprogress); published = SortTablePublishNote(sort2, published); dashboard.InProgressNotes = inprogress.ToList().AsQueryable().ToPagedList(page1 ?? 1, 5); dashboard.PublishedNotes = published.ToList().AsQueryable().ToPagedList(page2 ?? 1, 5); return(View(dashboard)); }
public static User Map(Context.Users user) => new User { Id = user.Id, UserName = user.UserName, LastName = user.LastName, FirstName = user.FirstName, Password = user.Password, Email = user.Email, Phone = user.Phone, DefaultLo = user.DefaultLo, Orders = Map(user.Orders).ToList() };
public string Create(Parameters parameters) { var user = new Context.Users(); user.id = int.Parse(parameters.id); user.login = parameters.login; user.password = parameters.password; context.Users.Add(user); context.SaveChanges(); return("Успешно добавлено"); }
public bool CreateUser(string login, string password) { var user = new Context.Users(); user.login = login; user.password = password; int maxId = context.Users.Max(x => x.id); user.id = maxId + 1; context.Users.Add(user); context.SaveChanges(); return(true); }
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 ForgotPassword(Models.ForgotPassword model) { if (ModelState.IsValid) { var isExist = IsEmailExist(model.EmailID); if (isExist == false) { ModelState.AddModelError("EmailID", "Email Does not exist"); return(View(model)); } Context.Users obj = dbobj.Users.Where(x => x.EmailID == model.EmailID).FirstOrDefault(); string pwd = Membership.GeneratePassword(6, 2); obj.Password = pwd; dbobj.SaveChanges(); SendPassword(obj.EmailID, pwd); TempData["Success"] = "New password has been sent to your email"; return(RedirectToAction("ForgotPassword")); } else { ModelState.AddModelError("EmailID", "Email is required"); return(View(model)); } }
public ActionResult MemberDetail(int member, string sort, int?page) { ViewBag.Sort = sort; ViewBag.PageNumber = page; ViewBag.Member = member; // get id of note status draft var draftid = dobj.ReferenceData.Where(x => x.Value.ToLower() == "draft").Select(x => x.ID).FirstOrDefault(); // get member Context.Users users = dobj.Users.Where(x => x.ID == member).FirstOrDefault(); UserProfileDetail userprofiles = dobj.UserProfileDetail.Where(x => x.UserID == users.ID).FirstOrDefault(); // get member's notes excluding note status draft var notes = dobj.NoteDetail.Where(x => x.SellerID == users.ID && x.Status != draftid).ToList(); // create list of MemberDetail.MembersNote var notelist = new List <MemberDetail.MembersNote>(); foreach (var note in notes) { // get data of downloaded notes for count how many people downloaded notes and get total earning var downloadednoteslist = dobj.Downloads.Where(x => x.NoteID == note.ID && x.IsSellerHasAllowedDownload == true && x.AttachmentPath != null); // create membernote object of MemberDetail.MembersNote var membernote = new MemberDetail.MembersNote(); membernote.ID = note.ID; membernote.Title = note.Title; membernote.Category = note.NoteCategories.Name; membernote.Status = note.ReferenceData.Value; membernote.DownloadedNotes = downloadednoteslist.Count(); membernote.TotalEarning = downloadednoteslist.Select(x => x.PurchasedPrice).Sum(); membernote.DateAdded = note.CreatedDate; membernote.PublishedDate = note.PublishedDate; // add membernote object to notelist notelist.Add(membernote); } // create object of MemberDetail MemberDetail members = new MemberDetail(); members.FirstName = users.FirstName; members.LastName = users.LastName; members.Email = users.EmailID; if (userprofiles != null) { members.DOB = userprofiles.DOB; members.PhoneNumberCountryCode = userprofiles.CountryCode; members.PhoneNumber = userprofiles.PhoneNumber; members.College = userprofiles.University; members.Address1 = userprofiles.AddressLine1; members.Address2 = userprofiles.AddressLine2; members.City = userprofiles.City; members.State = userprofiles.State; members.ZipCode = userprofiles.ZipCode; members.Country = userprofiles.Country; members.ProfilePicture = userprofiles.ProfilePicture; } IEnumerable <MemberDetail.MembersNote> note1 = notelist.AsEnumerable(); // sorting member notes result note1 = SortTableMemberNotes(sort, note1); members.Notes = note1.ToList().AsQueryable().ToPagedList(page ?? 1, 5); return(View(members)); }
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)); } }
public ActionResult EmailVerification(string code) { Context.Users obj = dbobj.Users.Where(x => x.SecretCode.ToString() == code).FirstOrDefault(); ViewBag.name = obj.FirstName; return(View(obj)); }