public ActionResult MessageReply(UserRequest userrequest) { userrequest.request_id = userrequest.request_id; userrequest.answer = userrequest.answer; userrequest.answer_user_id = 0; UserRequestAccess userreqAccsss = new UserRequestAccess(); //if autherizer person answered then reply send to relavent user via nortification and email int reslt = userreqAccsss.UpdateUserRequestAnswer(userrequest); if (reslt >= 0) { string body = "Title :" + userrequest.topic+ "< br />" + "Message :" + userrequest.message + "< br />" + "Answer :" + userrequest.answer + "< br />"; Email email = new Email(userrequest.email); email.SendMail(body, "Reply By Dealer Floor Plan Management Software team"); ViewBag.SuccessMsg = "Response will be delivered to your program inbox"; } else { ViewBag.SuccessMsg = "Error Occured"; } //retrieve not answersd list from database List<Models.UserRequest> result = new List<Models.UserRequest>(); UserRequest ob = new UserRequest(); UserRequestAccess userreques = new UserRequestAccess(); result = userreques.SelectDatalistForAnswer(); ob.RequestList = result; return View(ob); }
public ActionResult Index(ForgotPassword forgotPassword) { int userId = (new UserAccess()).getUserId(forgotPassword.Email); // if user doesn't exist if (userId == 0) { // pass error message and return the page ViewBag.ErrorMsg = "User Account not exists"; return View(); } string userName = (new UserAccess()).retreiveUserByUserId(userId).UserName; try { // generate token forgotPassword.token = forgotPassword.GenerateRandomString(30); // save it to db bool isUpdate = (new forgotPasswordTokenAccess()).updateToken(userId, forgotPassword.token); // if error exist, when save the detail pass the error message if (!isUpdate) { ViewBag.ErrorMsg = "Updating Failed"; return View(); } // send it to the user's email account Email email = new Email(forgotPassword.Email); int isSuccess = email.SendMail("Hi " + userName + " ! <br><br>We recieved a request to reset your password.<br><br> Click here to Reset Your password : <a href='"+ string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~")) + "ForgotPassword/ConfirmAccount?userId=" + userId + "&token=" + forgotPassword.token + "'>Link</a><br> If you don't want to change your password, you can ignore this email.<br><br> Thanks,<br> The Futunet Net Team", "Account - Help (Reset Your Password)"); // if sending failed -- return the page with error if (isSuccess == 0) { ViewBag.errorMsg = "Sending Mail Failed"; return View(); } } catch (Exception ex) { throw ex; } // return the page with success ViewBag.Message = "Instructions on how to reset Your Password have been sent to your inbox"; return View(); }
public ActionResult Create(User user) { int currentUser =0; try { currentUser = int.Parse(Session["userId"].ToString()); } catch (Exception) { return RedirectToAction("UserLogin", "Login"); } user.CreatedBy = _createById; user.IsDelete = false; user.Status = false; //Set admin branch to new user if (_curUserRoleId == 2) { user.BranchId = _curBranchId; } //Check role is selected if (user.RoleId == 0) user.RoleId = 2; //Check branch is selected if (_curUserRoleId == 1 && user.BranchId == 0) { user.BranchId = _curBranchId; } string passwordTemp = user.Password; UserAccess ua = new UserAccess(); string newSalt = PasswordEncryption.RandomString(); user.Password = PasswordEncryption.encryptPassword(user.Password, newSalt); user.Email = user.NewEmail; //Check this CompanyAccess ca = new CompanyAccess(); Company company = new Company();//ca.GetCompanyDetailsByFirstSpUserId(currentUser); //Insert user user.Company_Id = company.CompanyId; int res = ua.InsertUser(user); //Insert new user to user activation table string activationCode = Guid.NewGuid().ToString(); int userId = (new UserAccess()).getUserId(user.Email); res = ua.InsertUserActivation(userId, activationCode); if (res == 1) { ViewBag.SuccessMsg = "Data Successfully inserted!"; string body = "Hi " + user.FirstName + "! <br /><br /> Your account has been successfully created. Below in your account detail." + "<br /><br /> User name: " + user.UserName + "<br /> Password : <b>" + passwordTemp + "<br />Click <a href='http://localhost:57318/CreateUser/ConfirmAccount?userId=" + userId + "&activationCode=" + activationCode + "'>here</a> to activate your account." + "<br /><br/> Thanks,<br /> Admin."; Email email = new Email(user.Email); email.SendMail(body, "Account details"); // check the user as superadmin or admin.. if (user.RoleId == 1 || user.RoleId == 2) { ViewBag.SuccessMsg = "User Successfully Created"; return RedirectToAction("create",new { lbls = ViewBag.SuccessMsg }); } Session["editUserIds"] = userId; return RedirectToAction("SetRights", "EditRights", new {@lbl1 = ViewBag.SuccessMsg }); } else { ViewBag.ErrorMsg = "Failed to create user!"; //Restrict to create above user role RoleAccess ra = new RoleAccess(); List<UserRole> roleList = ra.GetAllUserRoles(); List<UserRole> tempRoleList = new List<UserRole>(); for (int i = roleList[_curUserRoleId - 1].RoleId; i <= roleList.Count && _curUserRoleId != 3; i++) { UserRole tempRole = new UserRole() { RoleId = roleList[i - 1].RoleId, RoleName = roleList[i - 1].RoleName }; tempRoleList.Add(tempRole); } ViewBag.RoleId = new SelectList(tempRoleList, "RoleId", "RoleName"); // get all branches List<Branch> branchesLists = (new BranchAccess()).getBranches(_companyId); ViewBag.BranchId = new SelectList(branchesLists, "BranchId", "BranchName"); return PartialView("Create"); } }
public ActionResult UserRequestMessagePost(UserRequest userReq) { //if (this.Session["CaptchaImageText"].ToString() == userReq.captcha) //{ string loancod = ""; string page_nam = ""; userReq.company_id = userData.Company_Id; userReq.branch_id = userData.BranchId; userReq.user_id = userData.UserId; userReq.role_id = userData.RoleId; if (Session["loanCode"] != null) { loancod = Session["loanCode"].ToString(); } if (Session["pagetitle"] != null) { page_nam = Session["pagetitle"].ToString(); } userReq.loan_code = loancod; userReq.page_name = page_nam; userReq.topic = userReq.topic; userReq.message = userReq.message; userReq.priority_level = "high"; UserRequestAccess userreqAccsss = new UserRequestAccess(); int reslt = userreqAccsss.InsertUserRequest(userReq); if (reslt >= 0) { string body = "User Name :" + userData.UserName + "< br />" + "Position :" + (string)Session["searchType"] + "< br />" + "Company :" + userData.CompanyName + "< br />" + "Branch :" + userData.BranchName + "< br />" + "Loan :" + loancod + "< br />" + "Date and Time :" + DateTime.Now + "< br />" + "Title :" + userReq.topic + "< br />" + "Message :" + userReq.message + "< br />" + "Page :" + page_nam + "< br />"; Email email = new Email("*****@*****.**"); email.SendMail(body, "User Request From Dealer Floor Plan Management Software"); ViewBag.SuccessMsg = "Response will be delivered to your program inbox"; return RedirectToAction("UserRequestMessage", "UserManagement"); } else { ViewBag.SuccessMsg = "Error Occured"; return RedirectToAction("UserRequestMessage"); } //} //else { // TempData["message"] = userReq.message; // TempData["topic"] = userReq.message; // return RedirectToAction("UserRequestMessage"); //} }
public ActionResult CreateDashboardUser(User userObj) { //assign phone number to object property userObj.PhoneNumber = userObj.PhoneNumber2; //assign user id to variable int currentUser = userData.UserId; // assign role to variable int roleId = userData.RoleId; //assign current user id to created by property userObj.CreatedBy = currentUser; //is delete property as false userObj.IsDelete = false; //encrypt password string passwordTemp = userObj.Password; UserAccess ua = new UserAccess(); DashBoardAccess da = new DashBoardAccess(); string newSalt = PasswordEncryption.RandomString(); userObj.Password = PasswordEncryption.encryptPassword(userObj.Password, newSalt); userObj.Email = userObj.NewEmail; //assign logged user's company id to created user's company id userObj.Company_Id = userData.Company_Id; //check user role is admin if (roleId == 2) { //assign logged user's branch id to created user's branch id userObj.BranchId = userData.BranchId; } //check created user is super admin and logged user is super admin if ((userObj.RoleId == 1)&&(userData.RoleId==1)) { //assign logged user's step status to created user's step status userObj.step_status = userData.step_status; } //check created user is admin else if (userObj.RoleId == 2) { //get step status for given branch id int step= ua.GetStepStatusByUserBranchId(userObj.BranchId); //check step is 0 or greater than 0 if(step>=0) { //assign step to created user's step status userObj.step_status = step; } } //check created user is user else if (userObj.RoleId == 3) { //check Session["LoanTitle"] is not null if (Session["LoanTitle"] != null) { //convert session to list List<Branch> loanList = (List<Branch>)Session["LoanTitle"]; for (var j = 0; j < loanList.Count; j++) { //check created user's loan id if (loanList[j].LoanId == userObj.LoanId) { foreach (Right rgt1 in userObj.UserRightsList) { //check title is needed to be tracked for created user's loan if (!loanList[j].IsTitleTrack && rgt1.rightId == "U02") { //assign title page rights as false if title is not needed to be tracked rgt1.active = false; } //check if there is atleast one fee for created user's loan if (!loanList[j].HasFee && rgt1.rightId == "U07") { //assign fee page rights as false if there is no atleast one fee rgt1.active = false; } } //check report rights according to the loan setup details foreach(Right rgt in userObj.ReportRightsList) { //check title need to be tracked and related right id if(!loanList[j].IsTitleTrack && rgt.rightId== "R04") { rgt.active = false; } //check loan has advance fee and related right id for advance fee invoice if (!loanList[j].HasAdvanceFee && rgt.rightId == "R07") { rgt.active = false; } //check loan has advance fee and related right id for advance fee receipt if (!loanList[j].HasAdvanceFee && rgt.rightId == "R08") { rgt.active = false; } //check loan has monthly fee and related right id for monthly fee invoice if (!loanList[j].HasMonthlyFee && rgt.rightId == "R09") { rgt.active = false; } //check loan has monthly fee and related right id for monthly fee receipt if (!loanList[j].HasMonthlyFee && rgt.rightId == "R10") { rgt.active = false; } //check loan has lot inspection fee and related right id for lot inspection fee invoice if (!loanList[j].HasLotFee && rgt.rightId == "R11") { rgt.active = false; } //check loan has lot inspection fee and related right id for lot inspection fee receipt if (!loanList[j].HasLotFee && rgt.rightId == "R12") { rgt.active = false; } } } } } //assign 1 for created user's step status userObj.step_status= 1; //assign selected branch id for created user's branch id userObj.BranchId = userObj.BranchIdUser; string[] arrList = new string[userObj.UserRightsList.Count]; string[] arrList2 = new string[userObj.ReportRightsList.Count]; int i = 0; int k = 0; //create user right list string by checking each right in right list active status foreach (var x in userObj.UserRightsList) { if (x.active) { arrList[i] = x.rightId; i++; } } //create user report right list string by checking each right in report right list active status foreach (var y in userObj.ReportRightsList) { if (y.active) { arrList2[k] = y.rightId; k++; } } arrList = arrList.Where(x => !string.IsNullOrEmpty(x)).ToArray(); userObj.UserRights = string.Join(",", arrList); //add report rights arrList2 = arrList2.Where(x => !string.IsNullOrEmpty(x)).ToArray(); userObj.ReportRights = string.Join(",", arrList2); } //Insert user details int res = da.InsertUserInDashboard(userObj); //check result of insert user function if (res > 0) { //update Companay Step States in incomplete Branches continued in dashboard StepAccess sa = new StepAccess(); sa.UpdateCompanySetupStep(userData.Company_Id, userObj.BranchId, 4); //if created user's status is active send email to inform his username and password if (userObj.Status) { string body = "Hi " + userObj.FirstName + "! <br /><br /> Your account has been successfully created. Below in your account detail." + "<br /><br /> User name: " + userObj.UserName + "<br /> Password : <b>" + passwordTemp + "<br /><br/> Thanks,<br /> Admin."; Email email = new Email(userObj.Email); email.SendMail(body, "Account details"); } string roleName = ""; //check created user is super admin if (userObj.RoleId == 1) { //assign role name as super admin roleName = "Super Admin"; } //check created user is admin else if (userObj.RoleId == 2) { //assign role name as admin roleName = "Admin"; } //check created user is user else if (userObj.RoleId == 3) { //assign role name as user roleName = "User"; } //insert log record Log log = new Log(userData.UserId, userData.Company_Id, userObj.BranchId, 0, "Create User", "Create "+roleName+" ,Username:"******"createUserResult"] = 1; //return RedirectToAction("CreateDashboardUser"); Session["LoanTitle"] = null; } else { TempData["createUserResult"] = 0; //return View(); } return RedirectToAction("CreateDashboardUser"); }
public string PayCurtailments(SelectedCurtailmentList selectedCurtailmentList, string needSend, string dealerEmail, string dueDate) { // if session expired -- return null if (Session["loanCode"] == null || Session["loanCode"].ToString() == "") return null; var loanCode = Session["loanCode"].ToString(); // take loan code from session string paidDate = ""; var loanDetails = (new LoanSetupAccess()).GetLoanDetailsByLoanCode(loanCode); // take loan details of the loan code CurtailmentAccess curtailmentAccess = new CurtailmentAccess(); string returnValue = curtailmentAccess.updateCurtailmets(selectedCurtailmentList, loanDetails.loanId, dealerEmail); // update curtailment details as paid // if curtailment successfully updated if (returnValue != null) { // saving for reporting purpose decimal totalpaid = 0.00M; List<CurtailmentShedule> selectedCurtailmentSchedules = selectedCurtailmentList.SelectedCurtailmentSchedules; foreach (var items in selectedCurtailmentSchedules) { items.PaidDate = items.PayDate.ToString("MM/dd/yyyy"); totalpaid += items.CurtAmount; paidDate = items.PaidDate; } foreach (var items in selectedCurtailmentSchedules) { items.TotalAmountPaid = totalpaid; } Session["CurtUnitDuringSession"] = selectedCurtailmentSchedules; if (needSend == "Yes") { ReportViewer rptViewerCurtailmentReceiptDuringSession = new ReportViewer(); rptViewerCurtailmentReceiptDuringSession.ProcessingMode = ProcessingMode.Local; rptViewerCurtailmentReceiptDuringSession.Reset(); rptViewerCurtailmentReceiptDuringSession.LocalReport.EnableExternalImages = true; rptViewerCurtailmentReceiptDuringSession.LocalReport.ReportPath = Server.MapPath("~/Reports/RptCurtailmentDuringSession.rdlc"); ReportAccess ra = new ReportAccess(); List<LoanDetailsRpt> details = ra.TopHeaderDetails(loanDetails.loanId, userData.UserId); foreach (var dates in details) { dates.ReportDate = DateTime.Now.ToString("MM/dd/yyyy"); } rptViewerCurtailmentReceiptDuringSession.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", details)); if (selectedCurtailmentSchedules != null && selectedCurtailmentSchedules.Count > 0) { try { rptViewerCurtailmentReceiptDuringSession.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", selectedCurtailmentSchedules)); Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; //create pdf file byte[] bytes = rptViewerCurtailmentReceiptDuringSession.LocalReport.Render( "PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); if (dealerEmail != "") { string mailSubject = "Curtailment Paid Receipt - Loan " + loanDetails.loanNumber; string mailBody = "Curtailments for Loan " + loanDetails.loanNumber + " which were due on or before " + dueDate + " have been paid on " + paidDate + ". " + "Please view the attached PDF file for full curtailment payment details. " + Environment.NewLine + Environment.NewLine + "Thank you," + Environment.NewLine + "Dealer Floor Plan Software Team"; Thread thread = new Thread(delegate () { Email email = new Email(dealerEmail); email.SendMailWithAttachment(mailSubject, mailBody, bytes); }); thread.IsBackground = true; thread.Start(); } } catch (Exception e) { throw e; } } } //insert to log string[] arrList = new string[selectedCurtailmentList.SelectedCurtailmentSchedules.Count]; int i = 0; // add all paid curtailment details to array foreach (var x in selectedCurtailmentList.SelectedCurtailmentSchedules) { if (!string.IsNullOrEmpty(x.UnitId)) { arrList[i] = "Pay Curtailment(s) for unit(s): " + x.IDNumber + " ,Curtailment No: " + x.CurtNumber + " ,Curtailment Amount:" + x.CurtAmount + " ,Paid Date:" + x.PayDate; i++; } } // join the array with comma seperated string units = string.Join(",", arrList); Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId, loanDetails.loanId, "Pay Curtailments", units, DateTime.Now); // insert into log int islog = (new LogAccess()).InsertLog(log); } // return the value return returnValue; }
public ActionResult LinkDealer(DealerUserModel user) { //initialize properties of user object user.PhoneNumber = user.PhoneNumber2; user.CreatedBy = userData.UserId; user.IsDelete = false; user.Status = true; user.Company_Id = userData.Company_Id; user.BranchId = userData.BranchId; user.RoleId = 4; user.Email = user.NewEmail; BranchAccess ba = new BranchAccess(); Loan loan = new Loan(); //Check Session["oneLoanDashboard"] is not null if (Session["oneLoanDashboard"] != null) { //convert session object to loan object loan = (Loan)Session["oneLoanDashboard"]; } //Check Session["loanDashboardJoinDealer"] is not null if (Session["loanDashboardJoinDealer"] != null) { //convert session object to loan object loan = (Loan)Session["loanDashboardJoinDealer"]; } //initialize non registered branch id user.NonRegBranchId = loan.NonRegBranchId; //initialize loan id user.LoanId = loan.LoanId; //encrypt given password string passwordTemp = user.Password; UserAccess ua = new UserAccess(); string newSalt = PasswordEncryption.RandomString(); user.Password = PasswordEncryption.encryptPassword(user.Password, newSalt); user.ActivationCode = Guid.NewGuid().ToString(); //report rights string[] arrList = new string[user.ReportRightsList.Count]; int k = 0; foreach (var y in user.ReportRightsList) { //Check whether a particular report right is given to user if (y.active) { arrList[k] = y.rightId; k++; } } arrList = arrList.Where(x => !string.IsNullOrEmpty(x)).ToArray(); user.ReportRights = string.Join(",", arrList); //Insert dealer user details and retrieve user id of inserted user int newUserId = ua.InsertDealerUser(user); //Check user id is not 0 if (newUserId != 0) { //Generate email to send username and password to created dealer user string body = "Hi " + user.FirstName + "! <br /><br /> Your account has been successfully created. Below in your account detail." + "<br /><br /> User name: " + user.UserName + "<br /> Password : <b>" + passwordTemp + "<br />Click <a href='www.dfpso.com'>here</a> to activate your account." + "<br /><br/> Thanks,<br /> Admin."; Email email = new Email(user.Email); Session["abcRol"] = user.RoleId; Session["abcBrnc"] = user.BranchId; email.SendMail(body, "Account details"); //insert log record after user is created Log log = new Log(userData.UserId, userData.Company_Id, user.BranchId, user.LoanId, "Create Dealer Account", "Inserted Dealer : " + user.UserName, DateTime.Now); int islog = (new LogAccess()).InsertLog(log); TempData["msg"] = 1; return RedirectToAction("LinkDealer"); } else { TempData["msg"] = 2; return RedirectToAction("LinkDealer"); } }
public ActionResult Step3(User user) { user.PhoneNumber = user.PhoneNumber2; int currentUser = userData.UserId; // check he is a super admin or admin int roleId = userData.RoleId; if (roleId > 2) { return new HttpStatusCodeResult(404,"You are not allowed"); } // check if step is 3... if (Convert.ToInt32(Session["companyStep"]) < 3) { return new HttpStatusCodeResult(404, "You are not allowed"); } user.CreatedBy = currentUser; user.IsDelete = false; // user.Status = false; string passwordTemp = user.Password; UserAccess ua = new UserAccess(); string newSalt = PasswordEncryption.RandomString(); user.Password = PasswordEncryption.encryptPassword(user.Password, newSalt); user.Email = user.NewEmail; //CompanyAccess ca = new CompanyAccess(); //Company company = ca.GetCompanyDetailsByFirstSpUserId(currentUser); user.Company_Id = userData.Company_Id;// company.CompanyId; - asanka //Set admin branch to new user if (roleId == 2) { user.BranchId = userData.BranchId; } user.step_status = userData.step_status; //Insert user int res = ua.InsertUser(user); if (res > 0) { //insert to log Log log = new Log(userData.UserId, userData.Company_Id, userData.BranchId,0, "Create User in Company setup", "created "+(user.RoleId == 1 ? "Super Admin" : "Admin") + ", Username : "******"Hi " + user.FirstName + "! <br /><br /> Your account has been successfully created. Below in your account detail." + "<br /><br /> User name: " + user.UserName + "<br /> Password : <b>" + passwordTemp + //"<br />Click <a href='http://localhost:57318/CreateUser/ConfirmAccount?userId=" + userId + "&activationCode=" + activationCode + "'>here</a> to activate your account." + "<br /><br/> Thanks,<br /> Admin."; Email email = new Email(user.Email); email.SendMail(body, "Account details"); } Session["abcRol"] = user.RoleId; Session["abcBrnc"] = user.BranchId; ViewBag.SuccessMsg = "User Successfully Created"; //additional page ----> Add User Rights //if() return RedirectToAction("Step3", new { lbls = ViewBag.SuccessMsg }); } else { ViewBag.ErrorMsg = "Failed to create user!"; //Restrict to create above user role RoleAccess ra = new RoleAccess(); List<UserRole> roleList = ra.GetAllUserRoles(); ViewBag.RoleId = new SelectList(roleList, "RoleId", "RoleName"); // User curUser = ua.retreiveUserByUserId(userId); // get all branches List<Branch> branchesLists = (new BranchAccess()).getBranches(userData.Company_Id); ViewBag.BranchId = new SelectList(branchesLists, "BranchId", "BranchName"); if (HttpContext.Request.IsAjaxRequest()) { ViewBag.AjaxRequest = 1; return RedirectToAction("Step3", new { lbls = ViewBag.ErrorMsg }); } else { return RedirectToAction("Step3", new { lbls = ViewBag.ErrorMsg }); } } }
/// <summary> /// Frontend Page: Add Unit /// Title: send request for advance if dealer user add units /// Designed: Piyumi Perera /// User story: /// Developed: Piyumi Perera /// Date created: 25/05/2016 /// </summary> /// <returns></returns> public ActionResult AddUnitRequestAdvance() { Models.User user = new Models.User(); //check session is null and if null return to dashboard if (Session["loanCode"] == null) { return RedirectToAction("UserDetails", "UserManagement"); } else { //convert session to string variable string Code = Session["loanCode"].ToString(); //get dealer user details for selected user user = (new UserAccess()).GetDealerUserDetails(userData.UserId, Code); //check object is not null if (user != null) { //send email to pointed user in order to request advance string alertmsg = " Dealer User " + user.FirstName + " " + user.LastName + " requested to advance " + user.NoOfUnitsAdded + " new unit(s) for loan number " + user.LoanNumber + " on " + user.AddedDate + ". Please go to advance page to advance the items. "; int rep = (new UserAccess()).InsertDearlerUserRequest(0,0,user.UserIdForSendReq, Code,alertmsg); string body = "Hi , <br /><br /> Dealer User " + user.FirstName + " " + user.LastName + " requested to advance " + user.NoOfUnitsAdded + " new unit(s) for loan number " + user.LoanNumber +" on "+user.AddedDate+". Please login to the system and go to advance page to advance item(s). <br /><br/> Thanks. <br />"; Email email = new Email(user.UserEmailForSendReq); email.SendMail(body, "Request Advance"); TempData["msg"] = 3; return RedirectToAction("AddUnit", "Unit"); } else { TempData["Msg"] = 0; return RedirectToAction("AddUnit", "Unit"); } } }