public ActionResult ChangePassword(ViewModelChangePassword model) { string role = string.Empty; if (model.NewPassword != model.RetypePassword) { ModelState.AddModelError("PasswordDontMatch", "'ReType New Password' and 'New Password' do not match"); return(View(model)); } using (IcasieEntities entity = new IcasieEntities()) { string currentUserEmail = HttpContext.User.Identity.Name; var user = entity.Users.SingleOrDefault(c => c.Email == currentUserEmail); string salt = user.Salt; string password = Icasie.Helper.Helper.CreatePasswordHash(model.NewPassword, salt); user.Password = password; role = user.Role; entity.SaveChanges(); System.Threading.Tasks.Task.Run(() => EmailHelper.SendEmailPasswordChange(user.Email, user.FirstName + " " + user.LastName, model.NewPassword)); } ViewData["message"] = " Your password succesfully changed"; return(View()); }
public ActionResult Register(int id, HttpPostedFileBase payment) { if (payment == null) { ModelState.AddModelError("payment", "Payment evidence cannot be empty"); } if (!ModelState.IsValid) { ViewModelParticipant participant = new ViewModelParticipant(); return(View(participant)); } using (IcasieEntities entity = new IcasieEntities()) { Participant part = new Participant(); string currentUserEmail = HttpContext.User.Identity.Name; var user = entity.Users.SingleOrDefault(c => c.Email == currentUserEmail); part.UserId = user.UserId; part.ConferenceId = id; part.PaymentFileName = payment.FileName; part.PaymentDate = DateTime.Now; part.PaymentStatus = Constant.PaymentStatus.Submitted; var fees = entity.Fees.ToList(); if (user.Country != Constant.Indonesia) { part.TotalPayment = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.OverseasParticipant)).Price; } else { part.TotalPayment = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.IndonesianParticipant)).Price; } using (Stream inputStream = payment.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } part.Payment = memoryStream.ToArray(); } entity.Participants.Add(part); entity.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Create(ViewModelConference model) { DateTime outStartDate = new DateTime(); DateTime outEndDate = new DateTime(); DateTime outPaperStartDate = new DateTime(); DateTime outPaperEndDate = new DateTime(); IFormatProvider provider = CultureInfo.CurrentCulture; if (!DateTime.TryParseExact(model.StartDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outStartDate)) { ModelState.AddModelError("StartDateString", "Start Date format is not valid"); } if (!DateTime.TryParseExact(model.EndDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outEndDate)) { ModelState.AddModelError("EndDateString", "End Date format is not valid"); } if (!DateTime.TryParseExact(model.PaperSubStartDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outPaperStartDate)) { ModelState.AddModelError("PaperSubStartDateString", "Paper Submission Start Date format is not valid"); } if (!DateTime.TryParseExact(model.PaperSubEndDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outPaperEndDate)) { ModelState.AddModelError("PaperSubEndDateString", "Paper Submission End Date format is not valid"); } if (!ModelState.IsValid) { return(View(model)); } using (IcasieEntities entity = new IcasieEntities()) { Conference conference = new Conference(); var prefix = model.Name.Replace(" ", ""); prefix = prefix.ToUpper(); conference.Name = model.Name; conference.StartDate = outStartDate; conference.EndDate = outEndDate; conference.PaperSubStartDate = outPaperStartDate; conference.PaperSubEndDate = outPaperEndDate; conference.LastSequenceNumber = prefix + "-" + Constant.NumberSuffix; conference.LastParticipantNumber = prefix + "-PART-" + Constant.NumberSuffix; entity.Conferences.Add(conference); entity.SaveChanges(); } return(RedirectToAction("Index")); }
private string GetLatestSequenceNumber(int conferenceId) { using (var db = new IcasieEntities()) { var conference = db.Conferences.SingleOrDefault(c => c.ConferenceId == conferenceId); var newSequenceNumber = NumberGenerator.NxtKeyCode(conference.LastSequenceNumber); conference.LastSequenceNumber = newSequenceNumber; db.SaveChanges(); return(newSequenceNumber); } }
public ActionResult VerifyPayment(int id, int conferenceId) { using (IcasieEntities entity = new IcasieEntities()) { var submission = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); submission.FullPaperStatus = Constant.FullPaperStatus.PaymentVerified; submission.PaymentVerificationDate = DateTime.Now; entity.SaveChanges(); } return(RedirectToAction("AuthorPayment", new { id = conferenceId })); }
public ActionResult EditProofReading(int id, HttpPostedFileBase file) { if (file == null) { ModelState.AddModelError("file", "File cannot be empty"); ViewModelSubmission sub = new ViewModelSubmission(); using (IcasieEntities entity = new IcasieEntities()) { var oldSub = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); sub.SubmissionId = oldSub.SubmissionId; sub.Title = oldSub.Title; sub.SubThemesId = oldSub.SubThemesId; } PrepareSelectList(); return(View(sub)); } using (IcasieEntities entity = new IcasieEntities()) { var sub = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); sub.FullPaperStatus = Constant.FullPaperStatus.Reviewed; sub.ProofReadingDate = null; sub.ProofReadingResultFileName = null; sub.ProofReadingResult = null; sub.Comment = Constant.InitialCommentProofRead; if (file != null) { using (Stream inputStream = file.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } sub.FullPaper = memoryStream.ToArray(); sub.FullPaperFileName = file.FileName; } } entity.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(ViewModelConference model) { DateTime outStartDate = new DateTime(); DateTime outEndDate = new DateTime(); DateTime outPaperStartDate = new DateTime(); DateTime outPaperEndDate = new DateTime(); IFormatProvider provider = CultureInfo.CurrentCulture; if (!DateTime.TryParseExact(model.StartDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outStartDate)) { ModelState.AddModelError("StartDateString", "Start Date format is not valid"); } if (!DateTime.TryParseExact(model.EndDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outEndDate)) { ModelState.AddModelError("EndDateString", "End Date format is not valid"); } if (!DateTime.TryParseExact(model.PaperSubStartDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outPaperStartDate)) { ModelState.AddModelError("PaperSubStartDateString", "Paper Submission Start Date format is not valid"); } if (!DateTime.TryParseExact(model.PaperSubEndDateString, Constant.DateFormatInput, provider, DateTimeStyles.None, out outPaperEndDate)) { ModelState.AddModelError("PaperSubEndDateString", "Paper Submission End Date format is not valid"); } if (!ModelState.IsValid) { return(View(model)); } using (IcasieEntities entity = new IcasieEntities()) { var odlConf = entity.Conferences.SingleOrDefault(c => c.ConferenceId == model.ConferenceId); odlConf.Name = model.Name; odlConf.StartDate = outStartDate; odlConf.EndDate = outEndDate; odlConf.PaperSubStartDate = outPaperStartDate; odlConf.PaperSubEndDate = outPaperEndDate; entity.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Register(ViewModelUser model, bool captchaValid) { if (!ModelState.IsValid) { return(View(model)); } string randomPassword = Icasie.Helper.Helper.GenerateRandomGuidPassword().Substring(0, 10); var random = new Random(); string salt = Icasie.Helper.Helper.CreateSalt(random.Next(10, 100)); string password = Icasie.Helper.Helper.CreatePasswordHash(randomPassword, salt); using (IcasieEntities entity = new IcasieEntities()) { if (entity.Users.Any(c => c.Email == model.Email)) { ViewData["message"] = "User already exist"; return(View(model)); } Icasie.Repositories.User user = new Icasie.Repositories.User(); user.Email = model.Email; user.City = model.City; user.Country = model.Country; user.FirstName = model.FirstName; user.LastName = model.LastName; user.Password = password; user.PhoneNumber = model.PhoneNumber; user.Role = model.Role; user.Salt = salt; user.State = model.State; user.StreetAddress = model.StreetAddress; user.Gender = model.Gender; user.Institution = model.Institution; entity.Users.Add(user); entity.SaveChanges(); System.Threading.Tasks.Task.Run(() => EmailHelper.SendEmailNewUser(model.Email, model.FirstName + " " + model.LastName, randomPassword, ConfigurationManager.AppSettings["SiteName"])); } return(View("RegisterSuccess")); }
public ActionResult VerifyPaymentParticipant(int id, string status, int conferenceId) { using (IcasieEntities entity = new IcasieEntities()) { var payment = entity.Participants.SingleOrDefault(c => c.ParticipantId == id); if (status == Constant.PaymentStatus.Accepted) { payment.Number = GetLatestSequenceNumber(conferenceId); payment.PaymentStatus = Constant.PaymentStatus.Accepted; } else { payment.PaymentStatus = Constant.PaymentStatus.Rejected; } entity.SaveChanges(); } return(RedirectToAction("ParticipantPayment", new { id = conferenceId })); }
public ActionResult Delete(int id) { bool isExist = false; using (IcasieEntities entity = new IcasieEntities()) { isExist = entity.Submissions.Any(c => c.ConferenceId == id); if (isExist == false) { var conference = entity.Conferences.SingleOrDefault(c => c.ConferenceId == id); entity.Conferences.Remove(conference); entity.SaveChanges(); } } if (isExist == true) { TempData["Message"] = "Conference cannot be deleted"; } return(RedirectToAction("index")); }
public ActionResult Assign(int reviewer, int submission, int proofReader, int formatChecker) { string conferenceName = string.Empty; string title = string.Empty; List <string> formatCheckerEmail = new List <string>(); using (var db = new IcasieEntities()) { var sub = db.Submissions.SingleOrDefault(c => c.SubmissionId == submission); conferenceName = db.Conferences.SingleOrDefault(c => c.ConferenceId == sub.ConferenceId).Name; title = sub.Title; sub.ReviewedBy = reviewer; sub.ProofReaderId = proofReader; sub.FormatCheckerId = formatChecker; db.SaveChanges(); formatCheckerEmail.Add(db.Users.SingleOrDefault(c => c.UserId == formatChecker).Email); } Task.Run(() => Helper.EmailHelper.SendEmailNotification(formatCheckerEmail, Constant.NotificationMode.AssignReviewer, conferenceName, title)); return(RedirectToAction("Assign")); }
public ActionResult SubmitPayment(int id, HttpPostedFileBase payment) { if (payment == null) { ModelState.AddModelError("payment", "Payment evidence cannot be empty"); } if (!ModelState.IsValid) { ViewModelSubmission sub = new ViewModelSubmission(); sub.SubmissionId = id; return(View(sub)); } using (IcasieEntities entity = new IcasieEntities()) { var sub = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); sub.PaymentFileName = payment.FileName; sub.FullPaperDate = DateTime.Now; sub.PaymentDate = DateTime.Now; using (Stream inputStream = payment.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } sub.Payment = memoryStream.ToArray(); } entity.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Reset(string id) { using (IcasieEntities entity = new IcasieEntities()) { var reset = entity.ResetPasswords.SingleOrDefault(c => c.Token.Equals(id)); var user = entity.Users.SingleOrDefault(c => c.UserId == reset.UserId); string randomPassword = Icasie.Helper.Helper.GenerateRandomGuidPassword().Substring(0, 10); var random = new Random(); string salt = Icasie.Helper.Helper.CreateSalt(random.Next(10, 100)); string password = Icasie.Helper.Helper.CreatePasswordHash(randomPassword, salt); user.Salt = salt; user.Password = password; entity.SaveChanges(); System.Threading.Tasks.Task.Run(() => EmailHelper.SendEmailResetPasswordSuccess(user.Email, user.FirstName + " " + user.LastName, randomPassword)); } return(View("ResetPasswordSuccess2")); }
public ActionResult ForgotPassword(ViewModelResetPassword model, bool captchaValid) { if (!ModelState.IsValid) { return(View()); } User user = new Repositories.User(); using (IcasieEntities entity = new IcasieEntities()) { user = entity.Users.SingleOrDefault(c => c.Email.Equals(model.Email)); if (user == null) { TempData["message"] = "We are not recognized the email you entered"; return(View()); } ResetPassword reset = new ResetPassword(); var rawToken = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); reset.Token = rawToken.Replace("/", ""); reset.UserId = user.UserId; reset.ExpDate = DateTime.Now; entity.ResetPasswords.Add(reset); entity.SaveChanges(); System.Threading.Tasks.Task.Run(() => EmailHelper.SendEmailPasswordReset(user.Email, user.FirstName + " " + user.LastName, reset.Token)); } return(View("ResetPasswordSuccess")); }
public ActionResult AddFullPaper(int id, string title, HttpPostedFileBase file, HttpPostedFileBase payment, int subThemesId, int coAuthors, int paymentType, bool termsAgreement) { List <string> adminEmails = new List <string>(); string conferenceName = string.Empty; //get user credential string currentUserEmail = HttpContext.User.Identity.Name; if (file == null) { ModelState.AddModelError("file", "File cannot be empty"); } if (payment == null) { ModelState.AddModelError("payment", "Payment Evidence cannot be empty"); } if (termsAgreement == false) { ModelState.AddModelError("termsAgreement", "You must accept this agreement to proceed"); } if (!ModelState.IsValid) { PrepareSelectList(); using (IcasieEntities entity = new IcasieEntities()) { PrepareViewData(entity); } return(View()); } Submission subs = new Submission(); subs.ConferenceId = id; subs.FullPaperFileName = file.FileName; subs.FullPaperDate = DateTime.Now; subs.PaymentFileName = payment.FileName; subs.PaymentDate = DateTime.Now; subs.PaperNumber = GetLatestSequenceNumber(id); subs.SubThemesId = subThemesId; subs.FullPaperStatus = Constant.FullPaperStatus.Pending; subs.Title = title; subs.CoAuthors = coAuthors; subs.PaymentType = paymentType; subs.Comment = Constant.InitialComment; subs.TermsAgreement = termsAgreement; using (Stream inputStream = file.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } subs.FullPaper = memoryStream.ToArray(); } using (Stream inputStream = payment.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } subs.Payment = memoryStream.ToArray(); } using (IcasieEntities entity = new IcasieEntities()) { var user = entity.Users.SingleOrDefault(c => c.Email.Equals(currentUserEmail)); var fees = entity.Fees.ToList(); decimal full = 0; decimal seminar = 0; decimal coauthor = 0; if (user.Country != Constant.Indonesia) { full = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.OverseasFull)).Price; seminar = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.OverseasSeminar)).Price; coauthor = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.OverseasCoauthor)).Price; } else { full = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.IndonesianFull)).Price; seminar = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.IndonesianSeminar)).Price; coauthor = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.IndonesianCoauthor)).Price; } subs.UserId = user.UserId; decimal total = 0; if (paymentType == Constant.PaymentType.Full) { total += full; } else { total += seminar; } total += (coAuthors * coauthor); subs.TotalPayment = total; entity.Submissions.Add(subs); entity.SaveChanges(); adminEmails = entity.Users.Where(c => c.Role.Equals(Constant.Role.Administrator)).Select(c => c.Email).ToList(); conferenceName = entity.Conferences.SingleOrDefault(c => c.ConferenceId == id).Name; } Task.Run(() => Helper.EmailHelper.SendEmailNotification(adminEmails, Constant.NotificationMode.NewSubmission, conferenceName, title)); return(RedirectToAction("Index")); }
public ActionResult EditFullPaper(int id, string title, HttpPostedFileBase file, int subThemesId, int coAuthors = 0, int paymentType = 0) { if (file == null) { ModelState.AddModelError("file", "File cannot be empty"); ViewModelSubmission sub = new ViewModelSubmission(); using (IcasieEntities entity = new IcasieEntities()) { var oldSub = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); sub.SubmissionId = oldSub.SubmissionId; sub.Title = oldSub.Title; sub.SubThemesId = oldSub.SubThemesId; sub.CoAuthors = oldSub.CoAuthors; sub.PaymentType = oldSub.PaymentType; sub.FullPaperStatus = oldSub.FullPaperStatus; PrepareViewData(entity); } PrepareSelectList(); return(View(sub)); } using (IcasieEntities entity = new IcasieEntities()) { var sub = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); sub.Title = title; //sub.FullPaperStatus = Constant.FullPaperStatus.Pending; sub.ReviewDate = null; sub.FullPaperReview = null; sub.FullPaperReviewFileName = null; sub.FullPaperReview2 = null; sub.FullPaperReviewFileName2 = null; sub.FullPaperReview3 = null; sub.FullPaperReviewFileName3 = null; sub.ProofReadingResult = null; sub.ProofReadingResultFileName = null; sub.FormatCheckingResult = null; sub.FormatCheckingResultFileName = null; sub.Comment = Constant.InitialComment; sub.SubThemesId = subThemesId; sub.CoAuthors = coAuthors; sub.PaymentType = paymentType; var user = entity.Users.SingleOrDefault(c => c.UserId == sub.UserId); if (sub.FullPaperStatus.Equals(Constant.FullPaperStatus.Pending)) { var fees = entity.Fees.ToList(); decimal full = 0; decimal seminar = 0; decimal coauthor = 0; if (user.Country != Constant.Indonesia) { full = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.OverseasFull)).Price; seminar = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.OverseasSeminar)).Price; coauthor = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.OverseasCoauthor)).Price; } else { full = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.IndonesianFull)).Price; seminar = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.IndonesianSeminar)).Price; coauthor = fees.SingleOrDefault(c => c.Name.Equals(Constant.Fees.IndonesianCoauthor)).Price; } decimal total = 0; if (paymentType == Constant.PaymentType.Full) { total += full; } else { total += seminar; } total += (coAuthors * coauthor); sub.TotalPayment = total; } else if (sub.FullPaperStatus.Equals(Constant.FullPaperStatus.FormatRevised)) { sub.FullPaperStatus = Constant.FullPaperStatus.PaymentVerified; } else if (sub.FullPaperStatus.Equals(Constant.FullPaperStatus.Revised)) { sub.FullPaperStatus = Constant.FullPaperStatus.FormatChecked; } else if (sub.FullPaperStatus.Equals(Constant.FullPaperStatus.ProofReadingRevised)) { sub.FullPaperStatus = Constant.FullPaperStatus.Reviewed; } if (file != null) { using (Stream inputStream = file.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } sub.FullPaper = memoryStream.ToArray(); sub.FullPaperFileName = file.FileName; } } entity.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id, string fullPaperStatus, string comment, HttpPostedFileBase file) { int conferenceId = 0; if (fullPaperStatus == Constant.FullPaperStatus.FormatRevised && file == null) { ModelState.AddModelError("file", "File cannot be empty"); } if (fullPaperStatus == Constant.FullPaperStatus.FormatRevised) { if (comment == null || comment == string.Empty) { ModelState.AddModelError("comment", "Comment is required"); } } if (!ModelState.IsValid) { ViewModelSubmission sub = new ViewModelSubmission(); using (IcasieEntities entity = new IcasieEntities()) { var oldSub = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); sub.SubmissionId = oldSub.SubmissionId; sub.Title = oldSub.Title; sub.FullPaperStatus = fullPaperStatus; sub.Comment = comment; } return(View(sub)); } try { using (IcasieEntities entity = new IcasieEntities()) { var sub = entity.Submissions.SingleOrDefault(c => c.SubmissionId == id); sub.Comment = comment; sub.FullPaperStatus = fullPaperStatus; conferenceId = sub.ConferenceId; sub.FormatCheckingDate = DateTime.Now; string currentUserEmail = HttpContext.User.Identity.Name; int userId = entity.Users.SingleOrDefault(c => c.Email == currentUserEmail).UserId; sub.FormatCheckerId = userId; if (fullPaperStatus == Constant.FullPaperStatus.FormatChecked) { sub.FormatCheckingResult = null; sub.FormatCheckingResultFileName = null; var conferenceName = entity.Conferences.SingleOrDefault(c => c.ConferenceId == sub.ConferenceId).Name; var title = sub.Title; List <string> reviewerEmail = new List <string>(); reviewerEmail.Add(entity.Users.SingleOrDefault(c => c.UserId == sub.ReviewedBy).Email); Task.Run(() => Helper.EmailHelper.SendEmailNotification(reviewerEmail, Constant.NotificationMode.AssignReviewer, conferenceName, title)); } else { if (file != null) { using (Stream inputStream = file.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } sub.FormatCheckingResult = memoryStream.ToArray(); sub.FormatCheckingResultFileName = file.FileName; } } } entity.SaveChanges(); } } catch (DbEntityValidationException ex) { } return(RedirectToAction("Index", new { id = conferenceId })); }