public JsonResult StartFollowUp(int?LoanId) { if (LoanId == null || DmlObj.GetLoanById(LoanId) == null) { return(Json(new { Id = 0, Message = "عملیات به دلیل خطا در دریافت اطلاعات تسهیلات انجام نشد" }, JsonRequestBehavior.AllowGet)); } var Loan = DmlObj.GetLoanById(LoanId); int UserId = 0; Int32.TryParse(User.GetAmUser(), out UserId); AMUser CurrentUser = DmlObj.GetAmUserById(UserId); if (CurrentUser == null) { return(Json(new { Id = 0, Message = "اطلاعات کاربری شما یافت نشد. لطفا دوباره به سیستم وارد شوید." }, JsonRequestBehavior.AllowGet)); } bool op = false; AMUpdateLoanLog UpdateLoanLogObj = DmlObj.AddStartFollowUpLoanLog(new AMUpdateLoanLog { LoanId = Loan.Id, UpdateTime = DateTime.Now, UserId = CurrentUser.Id, Status = Enum.UpdateLoanStatus.UnderProcess }, out op); if (op) { return(Json(new { Id = UpdateLoanLogObj.Id, FirstName = UpdateLoanLogObj.User.FirstName, LastName = UpdateLoanLogObj.User.Lastname, ElapsedTime = DisplayExtension.ElapsedTime(UpdateLoanLogObj.UpdateTime), Message = "در حال بررسی" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Id = 0, Message = "خطا در ذخیره سازی در پایگاه داده ها اتفاق افتاده است٬ لطفا مجددا تلاش نمایید." }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SetNotificationSeen(int?NotificationId) { if (NotificationId == null || DmlObj.GetInstallmentNotificationById(NotificationId) == null) { return(Json("یادآوری شناسایی نشد", JsonRequestBehavior.AllowGet)); } int UserId = 0; Int32.TryParse(User.GetAmUser(), out UserId); AMUser CurrentUser = DmlObj.GetAmUserById(UserId); if (CurrentUser == null) { return(Json("نام کاربری شناسایی نشد. لطفا دوباره به سیستم وارد شوید.", JsonRequestBehavior.AllowGet)); } if (DmlObj.SetInstallmentNotificationSeen(DmlObj.GetInstallmentNotificationById(NotificationId), CurrentUser)) { return(Json("با موفقیت ثبت شد", JsonRequestBehavior.AllowGet)); } return(Json("عملیات ناموفق بود٬ لطفا دوباره تلاش نمایید", JsonRequestBehavior.AllowGet)); }
public JsonResult UnConfirmInst(int?InstallmentId) { if (InstallmentId == null) { return(Json(new { Id = 0 }, JsonRequestBehavior.AllowGet)); } var k = DmlObj.GetInstallmentById(InstallmentId); if (k == null) { return(Json(new { Id = 0 }, JsonRequestBehavior.AllowGet)); } int UserId = 0; Int32.TryParse(User.GetAmUser(), out UserId); AMUser CurrentUser = DmlObj.GetAmUserById(UserId); if (CurrentUser == null) { return(Json(new { Id = 0 }, JsonRequestBehavior.AllowGet)); } return(Json(DmlObj.SetInstallmentsUnPaid(k, CurrentUser), JsonRequestBehavior.AllowGet)); }
public JsonResult RegisterCall(int?InstallmentId, int?AddressId, string CallDescription) { if (InstallmentId == null) { return(Json(new { Id = 0, message = "شناسایی قسط برای ثبت یادآوری ناموفق بود" }, JsonRequestBehavior.AllowGet)); } var k = DmlObj.GetInstallmentById(InstallmentId); if (k == null) { return(Json(new { Id = 0, message = "شناسایی قسط برای ثبت یادآوری ناموفق بود" }, JsonRequestBehavior.AllowGet)); } if (AddressId == null || AddressId < 1 || DmlObj.GetAddressById(AddressId) == null) { return(Json(new { Id = 0, message = "شماره تلفن یا آدرس انتخاب نشده است" }, JsonRequestBehavior.AllowGet)); } if (CallDescription == null || CallDescription.Length < 2) { CallDescription = "بدون توضیحات"; } AMUser CurrentUser = DmlObj.GetAmUserById(Int32.Parse(User.GetAmUser())); if (CurrentUser == null) { return(Json(new { Id = 0, message = "کاربر مجاز به انجام این عملیات نیست" }, JsonRequestBehavior.AllowGet)); } AMCall CallObj = new AMCall { Description = CallDescription, InstallmentId = k.Id, CallTime = DateTime.Now, AddressId = DmlObj.GetAddressById(AddressId).Id, UserId = CurrentUser.Id }; bool res = false; CallObj = DmlObj.SetCallInformation(CallObj, out res); if (res) { return(Json(new { Id = CallObj.Id, message = " با موفقیت ثبت شد." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Id = 0, message = "ثبت یادآوری نا موفق بود لطفا دوباره تلاش نمایید." }, JsonRequestBehavior.AllowGet)); } }
public JsonResult RegisterInstallmentNotification(int?InstallmentId, int?NotificationDays, string NotificationDescription) { if (InstallmentId == null) { return(Json("شناسایی قسط برای ثبت یادآوری ناموفق بود", JsonRequestBehavior.AllowGet)); } var k = DmlObj.GetInstallmentById(InstallmentId); if (k == null) { return(Json("شناسایی قسط برای ثبت یادآوری ناموفق بود", JsonRequestBehavior.AllowGet)); } if (NotificationDays == null || NotificationDays < 1) { return(Json("تعداد روز برای یادآوری را دوباره بررسی نمایید", JsonRequestBehavior.AllowGet)); } int UserId = 0; Int32.TryParse(User.GetAmUser(), out UserId); AMUser CurrentUser = DmlObj.GetAmUserById(UserId); if (CurrentUser == null) { return(Json("نام کاربری شناسایی نشد. لطفا دوباره به سیستم وارد شوید.", JsonRequestBehavior.AllowGet)); } if (NotificationDescription == null || NotificationDescription.Length < 2) { NotificationDescription = "بدون توضیحات"; } if (DmlObj.SetInstallmentNotification(new AMInstallmentNotification { Description = NotificationDescription, InstallmentId = k.Id, DueDate = DateTime.Now.AddDays((int)NotificationDays), Status = Enum.NotificationStatus.Unseen }, CurrentUser)) { return(Json("یادآوری با موفقیت ثبت شد.", JsonRequestBehavior.AllowGet)); } else { return(Json("ثبت یادآوری نا موفق بود لطفا دوباره تلاش نمایید.", JsonRequestBehavior.AllowGet)); } }
/* * this function checks if the default app user [email protected] already exists and creates it if it is not existing already * add also adds the default user to to Administrator role */ private static void DefaultUsers(UserManager <AMUser> userManager) { if (userManager.FindByNameAsync("*****@*****.**").Result == null) { var user = new AMUser { UserName = "******", Email = "*****@*****.**" }; var result = userManager.CreateAsync(user, "Elvis1$").Result; if (result.Succeeded) { userManager.AddToRoleAsync(user, "Administrator"); } } }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.UserName); if (user == null) { // Don't reveal that the user does not exist or is not confirmed return(View("UserNotFound")); } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); // return RedirectToAction("ForgotPasswordConfirmation", "Account"); int RandomCode = new Random().Next(111111, 999999); AMUser aMUser = DmlObj.GetAmUserFromAspUser(user.Id); if (aMUser == null) { return(View("Error")); } AMForgotPasswordCode ForgotModel = new AMForgotPasswordCode { UserId = aMUser.Id, UserName = user.UserName, Code = RandomCode, Expiration = DateTime.Now.AddDays(1) }; if (DmlObj.AddForgotPasswordCode(ForgotModel)) { return(RedirectToAction("ResetPasswordByCode", new { AspUserId = user.Id })); } } // If we got this far, something failed, redisplay form return(View(model)); }