Example #1
0
        public ActionResult RegisterEmployee_Post(RegisterViewModel model)
        {
            TempData["model"] = model;
            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }
            try
            {
                RegisterViewModel msgModel = new RegisterViewModel();
                int userId    = _de.InsertEmployee(model);
                var userCreds = _de.GetUserCredentialsbyUserId(userId);
                msgModel.Message       = "New Employee Registered with User Id " + userId;
                TempData["model"]      = msgModel;
                SMTPSender.ToAddress   = model.Email;
                SMTPSender.Subject     = "Registration successfull.";
                SMTPSender.MessageBody = "Welcome to GVB Expense Reimbursement tool. You are Sccussfully registered for the reimbursement of your expenses.\n \n Please login into the tool with below credentials.\n\n User Id: " + userCreds.UserId + "\n Password: "******"Index"));
            }
            catch (Exception ex)
            {
                model.Message = "Error occured while creating employee" + ex.InnerException.Message;
            }

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult ForgotPassword_Post(ForgotPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                string error = string.Empty;
                ModelState.Values.SelectMany(v => v.Errors).ToList().ForEach(e => error += e.ErrorMessage + "\n");
                return(Json(new { success = false, message = error }));
            }
            var employee = _de.GetEmployeeByEmpID(model.EmpId);

            if (employee != null && employee.EmailId.Equals(model.Email))
            {
                try
                {
                    string password = _de.ForgotPassword(model.EmpId);
                    SMTPSender.ToAddress   = model.Email;
                    SMTPSender.Subject     = "Password Recovery for Employee.";
                    SMTPSender.MessageBody = "Your password is given below. Please login to the application using this password.\n\n\n Password: "******"Password is sent to the employee through an email." }));
                }
                catch (Exception ex) {
                    return(Json(new { success = false, msg = ex.InnerException.Message }));
                }
            }
            return(Json(new { success = false, msg = "The employee id or email address is not found. Please try again with valid details." }));
        }
 public string ApproveReport(ExpenseReportEntity rpt)
 {
     _de.UpdateReportApprover(rpt);
     SMTPSender.ToAddress = _de.GetEmployeeByEmpID(rpt.EmpId).EmailId;
     SMTPSender.Subject   = "Report status updated";
     if (rpt.ApprovedAmt == 0)
     {
         SMTPSender.MessageBody = "Approver updated your report status to pending. Please check comments section to proceed with further actions.";
         SMTPSender.SendEmail();
         return("Updated successfully.");
     }
     SMTPSender.MessageBody = "Your report has been approved. Amount will be transferred to your account within one week.";
     SMTPSender.SendEmail();
     return("Report approved and confirmation sent to employee.");
 }