public async Task <ActionResult> StopWorkStatus() { string userID = Convert.ToString(Session["userid"]); var noOfRowsAffected = await accountRepository.StopWorkStatusOfAllUser(userID); ToastrNotificationService.AddSuccessNotification("Work Status of all user are changed to inactive", null); return(RedirectToAction("Index")); }
public ActionResult Delete(string id) { string loggedInUserID = Convert.ToString(Session["userid"]); if (id == loggedInUserID) { ToastrNotificationService.AddWarningNotification("You can not delete yourself", null); } else { accountRepository.DeleteUser(id); ToastrNotificationService.AddSuccessNotification("User deleted successfully", null); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(Users users) { if (ModelState.IsValid) { if (string.IsNullOrEmpty(users.UserID)) { users.UserID = Guid.NewGuid().ToString(); users.UserCreatedDate = DateTime.Now; users.UserCreatedByUserID = Convert.ToString(HttpContext.Session["userid"]); users.IsActive = true; users.MaxFormsCount = 698; users.UserRoles = "user"; Random rnd = new Random(); int randomNumber = rnd.Next(100000, 999999); users.OTP = randomNumber; await accountRepository.CreateUser(users); string strURL = this.Request.Url.Scheme + "://" + this.Request.Url.Host; if (!string.IsNullOrEmpty(Convert.ToString(this.Request.Url.Port))) { strURL = strURL + ":" + Convert.ToString(this.Request.Url.Port); } string verifyOTPUrl = $"{strURL}/Account/VerifyOTP/{users.UserID}"; string companyName = WebConfigurationManager.AppSettings["CompanyName"]; string companyURL = WebConfigurationManager.AppSettings["CompanyURL"]; string body = "Hello " + users.FirstName + " " + users.LastName + "," + "<br/><br/> Welcome to <b>" + companyName + "</b>" + "<br/><br/> Please click the following link to activate your account " + "<br/><a href=\"" + verifyOTPUrl + "\">click here</a><br/>" + "Use OTP code " + randomNumber.ToString() + " to activate your account.<br/><br/>" + "URL to Login:<a href=\"" + companyURL + "\">" + companyURL + "</a> <br/>Thank You."; await _emailSender.SendEmailAsync(users.Email, "Welcome to " + companyName, body); ToastrNotificationService.AddSuccessNotification("User Created Succesfully", null); return(RedirectToAction("Index")); } } return(View(users)); }
public async Task <ActionResult> ChangePassword(ChangePasswordDto changePasswordDto) { if (ModelState.IsValid) { string userid = Convert.ToString(HttpContext.Session["userid"]); if (!string.IsNullOrEmpty(userid)) { if (changePasswordDto.Password == changePasswordDto.NewPassword) { ToastrNotificationService.AddWarningNotification("Password and New Password can't be same", null); } else if (changePasswordDto.NewPassword != changePasswordDto.ConfirmPassword) { ToastrNotificationService.AddWarningNotification("New Password and Confirm Password must be same", null); } else { var user = accountRepository.GetUserByID(userid); if (user != null) { if (user.Password == changePasswordDto.Password) { await accountRepository.ChangePassword(changePasswordDto); ToastrNotificationService.AddSuccessNotification("Password changed successfully", null); return(RedirectToAction("Index", "Home")); } else { ToastrNotificationService.AddWarningNotification("Invaild Password", null); ModelState.AddModelError("Password", "Invaild Password"); } } } } } return(View(changePasswordDto)); }
public ActionResult FormQuery(CreateFormDto createFormDto, string id) { List <FormQuery> formQueryList = new List <FormQuery>(); foreach (var item in createFormDto.formQueryDtos) { if (item.IsChecked) { FormQuery formQuery = new FormQuery(); formQuery.FormQueryText = Convert.ToString(item.FormQuery.FormQueryText); formQuery.FormQueryStatus = "Pending"; formQuery.FormQueryCreatedDate = DateTime.Now; if (TempData.ContainsKey("UserID")) { LoggedInUserID = TempData.Peek("UserID").ToString(); } if (!string.IsNullOrEmpty(LoggedInUserID)) { formQuery.FormQueryCreatedByUserID = LoggedInUserID; } else { return(RedirectToAction("LogIn", "Account")); } formQueryList.Add(formQuery); } } formsRepository.CreateFormQuery(formQueryList); ToastrNotificationService.AddSuccessNotification("Query Saved Successfully", null); return(RedirectToAction("Create", "Form", new { id = id })); }
public async Task <ActionResult> Create(CreateFormDto createFormDto, string submit, string id) { if (TempData.ContainsKey("UserID")) { LoggedInUserID = TempData.Peek("UserID").ToString(); } if (string.IsNullOrEmpty(LoggedInUserID)) { return(RedirectToAction("LogIn", "Account")); } if (string.IsNullOrEmpty(id)) { int maxFormCount = await formsRepository.GetTotalSubmitedFormOfUser(LoggedInUserID); if (createFormDto.Forms.FormNo <= maxFormCount) { ToastrNotificationService.AddSuccessNotification("You already filled this form", null); return(RedirectToAction("Create")); } } Forms forms = new Forms(); forms.FirstName = createFormDto.Forms.FirstName; forms.LastName = createFormDto.Forms.LastName; forms.Email = createFormDto.Forms.Email; forms.SSN = createFormDto.Forms.SSN; forms.Phone = createFormDto.Forms.Phone; forms.BankName = createFormDto.Forms.BankName; forms.AccountNo = createFormDto.Forms.AccountNo; forms.LoanAmount = createFormDto.Forms.LoanAmount; forms.Address = createFormDto.Forms.Address; forms.City = createFormDto.Forms.City; forms.State = createFormDto.Forms.State; forms.Zip = createFormDto.Forms.Zip; forms.DOB = createFormDto.Forms.DOB; forms.LicenceNo = createFormDto.Forms.LicenceNo; forms.LicenceState = createFormDto.Forms.LicenceState; forms.IP = createFormDto.Forms.IP; forms.FormNo = createFormDto.Forms.FormNo; forms.FormImagePath = createFormDto.Forms.FormImagePath; if (submit == "Submit") { forms.FormIsSubmit = true; } else { forms.FormIsSubmit = false; } forms.FormsCreatedDate = DateTime.Now; forms.FormsCreatedByUserID = LoggedInUserID; try { var createdForm = await formsRepository.CreateForm(forms); } catch (Exception ex) { ToastrNotificationService.AddSuccessNotification("You already filled this form", null); return(RedirectToAction("Create")); } if (forms.FormIsSubmit) { ToastrNotificationService.AddSuccessNotification("Form Submited Successfully", null); return(RedirectToAction("Index", new { id = "submit" })); } ToastrNotificationService.AddSuccessNotification("Form Saved Successfully", null); return(RedirectToAction("Index", new { id = "save" })); }