public async Task<ActionResult> Login(string username, string password) { var refundAppRepo = new RefundApplicationRepository(); var existing = await refundAppRepo.FindIRD(username); if (existing.Count > 0) { Session["IRDNumber"] = username; Session["Title"] = existing.FirstOrDefault().Title; Session["FirstName"] = existing.FirstOrDefault().FirstName; Session["LastName"] = existing.FirstOrDefault().LastName; Session["Email"] = existing.FirstOrDefault().Email; Response.StatusCode = (int)HttpStatusCode.OK; return Json(new { success = true, irdNumber = Session["IRDNumber"], title = Session["Title"], firstName = Session["FirstName"], lastName = Session["LastName"], email = Session["Email"], }, JsonRequestBehavior.AllowGet); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { success = false, responseText = "User already exist." }, JsonRequestBehavior.AllowGet); } }
public async Task<ActionResult> List() { //var home = Umbraco.TypedContentAtRoot().First(); var refundApplicationRepository = new RefundApplicationRepository(); var refundApplication = await refundApplicationRepository.GetAll(); //return this.Json(refundApplication); var serializer = new JavaScriptSerializer(); var result = serializer.Serialize(refundApplication); return Json(result, JsonRequestBehavior.AllowGet); //return View(refundApplication); }
public async Task<ActionResult> Submit(RefundApplication refundApplication) { var home = Umbraco.TypedContentAtRoot().First(); var settings = Umbraco.TypedContent(1091); var email = home.GetProperty("mailTo").Value.ToString(); var emailFrom = settings.GetProperty("fromEmail").Value.ToString(); var smtpServer = settings.GetProperty("smtpServer").Value.ToString(); var smtpUsername = settings.GetProperty("smtpUsername").Value.ToString(); var smtpPassword = settings.GetProperty("smtpPassword").Value.ToString(); refundApplication.ApplicationDate = SetDateForMongo(DateTime.Now); var refundApplicationRepository = new RefundApplicationRepository(); await refundApplicationRepository.CreateSync(refundApplication); var mailService = new MailService(); mailService.Send(email, Server.MapPath("~/RegistrationNotification.html"), "", refundApplication, smtpServer, smtpUsername, smtpPassword, emailFrom); return Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet); }
public async Task<ActionResult> ForgotPassword(string email) { var refundAppRepo = new RefundApplicationRepository(); var existing = await refundAppRepo.FindByEmail(email); if (existing.Count > 0) { var password = existing.FirstOrDefault().Password; var mail = new MailService(); mail.SendPassword(email, password); Response.StatusCode = (int)HttpStatusCode.OK; return Json(new { success = true }, JsonRequestBehavior.AllowGet); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { success = false, responseText = "User already exist." }, JsonRequestBehavior.AllowGet); } }
private async Task<bool> UpdateRecord(RefundApplication refundApplication) { var refundApplicationRepo = new RefundApplicationRepository(); return await refundApplicationRepo.Update(refundApplication.IRDNumber, refundApplication.Title, refundApplication.FirstName, refundApplication.LastName, refundApplication.Email); }
public async Task<ActionResult> Register(string username, string password) { var refundAppRepo = new RefundApplicationRepository(); var existing = await refundAppRepo.FindIRD(username); if (existing.Count == 0) { var refunApp = new RefundApplication { IRDNumber = username, Password = password }; await refundAppRepo.CreateSync(refunApp); Session["IRDNumber"] = username; Response.StatusCode = (int)HttpStatusCode.OK; return Json(new { success = true, responseText = "Added." }, JsonRequestBehavior.AllowGet); } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; return Json(new { success = false, responseText = "User already exist." }, JsonRequestBehavior.AllowGet); } }