// public JsonResult SendEmailToUser(int pMarkTo,int FileNo) // { // // var data = _fileTransMainService.All().Select(x => x.MarkToID == pMarkTo).FirstOrDefault(); // var receivermail = _newStaffService.All().Where(x => x.StaffId == pMarkTo).Select(x => x.Email); // var senderId = _fileMainService.All().Where(x => x.FileNo == FileNo).Select(x => x.UserID).FirstOrDefault(); // var sendermail = _newStaffService.All().Where(x => x.StaffId == senderId).Select(x => x.Email); // bool result = false; // // result = SendEmail("data", "test subject", "<p>Hi Anna,</br> this mail is for check</p>"); // return Json(result, JsonRequestBehavior.AllowGet); // } //// public bool SendEmail(string toEmail, string subject, string emailBody) public bool SendEmail(int pMarkTo, string pFileNo) { try { var toEmail = _newStaffService.All().Where(x => x.StaffId == pMarkTo).Select(x => x.Email).FirstOrDefault(); var senderPassword = "******"; var senderId = _fileMainService.All().Where(x => x.FileNo == pFileNo).Select(x => x.UserID).FirstOrDefault(); var senderEmail = _newStaffService.All().Where(x => x.StaffId == senderId).Select(x => x.Email).FirstOrDefault(); string subject = "test subject"; string emailBody = "<p>Hi Anna,</br> this mail is for check</p>"; // string senderEmail = System.Configuration.ConfigurationManager.AppSettings["SenderEmail"].ToString(); //string senderPassword = System.Configuration.ConfigurationManager.AppSettings["SenderPassword"].ToString(); using (SmtpClient client = new SmtpClient()) { //SmtpClient client = new SmtpClient("smtp.gmail.com", 587); client.Host = "smtp.gmail.com"; client.Port = 587; client.EnableSsl = true; client.Timeout = 100000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(senderEmail, senderPassword); MailMessage mailMessage = new MailMessage(senderEmail, toEmail, subject, emailBody); mailMessage.IsBodyHtml = true; mailMessage.BodyEncoding = UTF8Encoding.UTF8; client.Send(mailMessage); return(true); } } catch (Exception ex) { return(false); } }
public ActionResult Login(VMLogin user) { string Pass = EncryptionDecryption.DH_PEncode(user.Password); string Uname = EncryptionDecryption.DH_PEncode(user.UserName); var userInfo = (from mi in _newStaffService.All().ToList() where mi.LoginName == Uname && mi.Password == Pass select new { UserID = mi.StaffId, UserName = mi.LoginName, Password = mi.Password, Email = mi.Email }).FirstOrDefault(); if (userInfo != null) { Session["UserID"] = userInfo.UserID; Session["UserName"] = userInfo.UserName; return(RedirectToAction("Index", "Home")); } else { ViewBag.Message = "Login data is incorrect!"; return(RedirectToAction("Authentication", "Authentication")); } }
public ActionResult NewStaff() { ViewBag.Id = _newStaffService.All().Select(x => x.StaffId).LastOrDefault() + 1; ViewBag.BoundaryId = LoadDropDown.LoadBoundary(_boundaryService); ViewBag.ReportingId = LoadDropDown.LoadReportingTo(_newStaffService); return(View()); }
public static SelectList LoadReportingTo(IStaffAppService _newStaffService) { var items = _newStaffService.All().ToList() .Select(x => new { x.StaffId, x.StaffName }).ToList(); //items.Insert(0, new { Id = "", BoundaryName = "---- Select ----" }); return(new SelectList(items.OrderBy(x => x.StaffName), "StaffId", "StaffName")); }
public ActionResult Index() { ViewBag.MarkTo = LoadDropDown.LoadReportingTo(_newStaffService); var ReportingName = _newStaffService.All().Where(x => x.StaffId == Convert.ToInt32(Session["UserID"])).Select(x => x.ReportingId).FirstOrDefault(); //ViewBag.MarkTo = _newStaffService.All().Where(x => x.StaffId == ReportingName).Select(x => x.StaffName).FirstOrDefault(); ViewBag.Action = LoadDropDown.LoadActionList(_actionListService); ViewBag.Id = _newStaffService.All().Select(x => x.StaffId).LastOrDefault() + 1; ViewBag.BoundaryId = LoadDropDown.LoadBoundary(_boundaryService); ViewBag.ReportingId = LoadDropDown.LoadReportingTo(_newStaffService); //ViewBag.Items = GetAllItem(); return(View()); }
public ActionResult UpdateSignature(SignaturePin signature) { using (var transaction = new TransactionScope()) { try { var userId = Convert.ToInt32(Session["UserID"].ToString()); var userInfo = _newStaffService.All().Where(x => x.StaffId == userId).FirstOrDefault(); userInfo.Password = EncryptionDecryption.DH_PEncode(signature.Pin); //(signature.Pin); userInfo.ConfirmPass = EncryptionDecryption.DH_PEncode(signature.ConfirmPin); _newStaffService.Update(userInfo); _newStaffService.Save(); transaction.Complete(); return(Json("1", JsonRequestBehavior.AllowGet)); } catch (Exception) { transaction.Dispose(); return(Json("0", JsonRequestBehavior.AllowGet)); } } }