/// <summary> /// This method is used to authenticate a users login /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <returns></returns> public AppUser AuthenticateAppUserLogin(string email, string password) { var hashPassword = new Md5Encryption().ConvertStringToMd5Hash(password.Trim()); var user = new AppUserFactory().GetAppUserByLogin(email, hashPassword); return(user); }
public IActionResult Index(string id) { if (!String.IsNullOrEmpty(id)) { var appUserKeys = new AppUserFactory().GetUsersAccessKey(new AppConfig().FetchUsersAccessKeys); var userKey = appUserKeys.Result.SingleOrDefault(n => n.AccountActivationAccessCode == id); if (userKey != null) { var user = new AppUserFactory().GetAllUsers(new AppConfig().FetchUsersUrl).Result .SingleOrDefault(n => n.AppUserId == userKey.AppUserId); if (user != null) { var userSession = JsonConvert.SerializeObject(user); var imageCount = _databaseConnection.Images.Where(n => n.AppUserId == user.AppUserId).ToList().Count; HttpContext.Session.SetString("StudioLoggedInUserId", userKey.AppUserId.ToString()); HttpContext.Session.SetString("StudioLoggedInUser", userSession); HttpContext.Session.SetInt32("StudioLoggedInUserImageCount", imageCount); return(RedirectToAction("Dashboard")); } } } if (HttpContext.Session.GetString("StudioLoggedInUserId") != null && HttpContext.Session.GetString("StudioLoggedInUser") != null) { return(RedirectToAction("Dashboard")); } return(Redirect("https://camerack.com/Account/Login?returnUrl=sessionExpired")); }
public ActionResult ProfileDetails(string Id) { var userId = Convert.ToInt64(new Md5Ecryption().DecryptPrimaryKey(Id, true)); var user = new AppUserFactory().GetAppUserById((int)userId); Session["viewprofilebyotheruser"] = user; return(View("ProfileDetails", user)); }
public ActionResult ForgotPasswordLink(AccountModel model) { model.ClientId = new AppConfig().ClientId; var response = new AppUserFactory().ForgetPasswordLink(new AppConfig().ForgotPasswordLinkUrl, model).Result; //display notification TempData["display"] = response.AccessLog.Message; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Login")); }
public AppUserEntity GetAppUser(Guid userId) { AspnetAppUsers aspnetAppUserModel = checkNetDbContext.AspnetAppUsers.Find(userId); AppUserEntity appUserEntity = AppUserFactory.Create(aspnetAppUserModel.UserId, aspnetAppUserModel.FkAspnetAppCustomersCustNo , aspnetAppUserModel.CurrentUserProviderKey, aspnetAppUserModel.SelectedFileGroup, aspnetAppUserModel.SelectedFileGuid , aspnetAppUserModel.StatusCode, aspnetAppUserModel.EmailAddress, aspnetAppUserModel.FirstName, aspnetAppUserModel.LastName , aspnetAppUserModel.ReceiveStatusEmails, aspnetAppUserModel.ExportType, aspnetAppUserModel.LastUpdatedBy , aspnetAppUserModel.LastUpdateDate, aspnetAppUserModel.FileUploadMode); return(appUserEntity); }
public IActionResult GeneralNotice(UserEmail email) { var users = new AppUserFactory().GetAllUsers(new AppConfig().FetchUsersUrl).Result.ToList(); email.MessageCategory = "General"; email.AppUsers = users; new SendUserMessage().SendGeneralNotice(email); //display notification TempData["display"] = "You have successfully sent the General Notice!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Dashboard", "Home")); }
/// <summary> /// This method is used to send a forgot password request to fetch the user /// </summary> /// <param name="email"></param> /// <returns></returns> public AppUser ForgotPasswordRequest(string email) { email = email.Trim(); var user = new AppUserFactory().GetAppUserByEmail(email); var appuser = _db.AppUsers.Find(user.AppUserId); var newPassword = Membership.GeneratePassword(8, 1); appuser.Password = newPassword; _db.Entry(appuser).State = EntityState.Modified; _db.SaveChanges(); //new MailerDaemon().ResetUserPassword(appuser); return(user); }
public ActionResult Create( [Bind( Include = "AppUserId,Firstname,Lastname,Othername,Email,MobileNumber,DepartmentId" )] AppUser appUser, FormCollection collectedValues) { if (ModelState.IsValid) { var loggedinuser = Session["courseshuffleloggedinuser"] as AppUser; if ((loggedinuser != null) && (loggedinuser.Role == UserType.Administrator.ToString())) { if (collectedValues["Role"] == null) { TempData["user"] = "******"; TempData["notificationtype"] = NotificationType.Danger.ToString(); return(View(appUser)); } var profileImage = Request.Files["avatar-2"]; appUser.DateCreated = DateTime.Now; appUser.DateLastModified = DateTime.Now; appUser.LastModifiedBy = loggedinuser.AppUserId; appUser.CreatedBy = loggedinuser.AppUserId; appUser.Role = typeof(UserType).GetEnumName(int.Parse(collectedValues["Role"])); var password = Membership.GeneratePassword(8, 1); var hashPassword = new Md5Ecryption().ConvertStringToMd5Hash(password.Trim()); appUser.Password = new RemoveCharacters().RemoveSpecialCharacters(hashPassword); appUser.ProfilePicture = new FileUploader().UploadFile(profileImage, UploadType.ProfileImage.ToString()); _db.AppUsers.Add(appUser); var userExist = new AppUserFactory().CheckIfGeneralUserExist(appUser.Email.Trim()); if (userExist) { TempData["user"] = "******"; TempData["notificationtype"] = NotificationType.Danger.ToString(); return(View(appUser)); } _db.SaveChanges(); appUser.Password = password; new MailerDaemon().NewUser(appUser); TempData["user"] = "******"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); } TempData["user"] = "******"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(_db.Departments, "DepartmentId", "Name"); return(View(appUser)); }
public ActionResult ResetPassword(int Id) { var token = Session["token"]; var user = new AppUserFactory().GetAppUserById(Id); var passwordReset = _dbc.PasswordResets.ToList(); var userPasswordReset = passwordReset.Single(n => n.AppUserId == Id && n.Token == (string)token); if (userPasswordReset.ExpiryDate < DateTime.Now) { TempData["password"] = "******"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(View("Login")); } return(View(user)); }
public IActionResult AllUsers() { try { var users = new AppUserFactory().GetAllUsers(new AppConfig().FetchUsersUrl).Result.ToList(); return(View(users)); } catch (Exception) { //display notification TempData["display"] = "An error ocurred while fetching your orders check your internet connectivity and try again!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View()); } }
public List <AppUserEntity> GetAppUsers() { List <AspnetAppUsers> AppUserEntitiesModels = checkNetDbContext.AspnetAppUsers.ToList(); List <AppUserEntity> AppUserEntities = new List <AppUserEntity>(); foreach (AspnetAppUsers aspnetAppUserModel in AppUserEntitiesModels) { AppUserEntity appUserEntity = AppUserFactory.Create(aspnetAppUserModel.UserId, aspnetAppUserModel.FkAspnetAppCustomersCustNo , aspnetAppUserModel.CurrentUserProviderKey, aspnetAppUserModel.SelectedFileGroup, aspnetAppUserModel.SelectedFileGuid , aspnetAppUserModel.StatusCode, aspnetAppUserModel.EmailAddress, aspnetAppUserModel.FirstName, aspnetAppUserModel.LastName , aspnetAppUserModel.ReceiveStatusEmails, aspnetAppUserModel.ExportType, aspnetAppUserModel.LastUpdatedBy , aspnetAppUserModel.LastUpdateDate, aspnetAppUserModel.FileUploadMode); AppUserEntities.Add(appUserEntity); } return(AppUserEntities); }
public IActionResult PhotographersNotice(UserEmail email) { var users = new AppUserFactory().GetAllUsers(new AppConfig().FetchUsersUrl).Result.ToList(); var results = (from a in users join b in _databaseConnection.Images.ToList() on a.AppUserId equals b.AppUserId where b != null select a).Distinct().ToList(); email.MessageCategory = "General"; email.AppUsers = results; new SendUserMessage().SendGeneralNotice(email); //display notification TempData["display"] = "You have successfully sent the Photographers Notice!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Dashboard", "Home")); }
public async Task <ActionResult> AccountActivationLink(string accessCode) { var accessKey = new AppUserFactory().GetUsersAccessKey(new AppConfig().FetchUsersAccessKeys) .Result.SingleOrDefault(n => n.PasswordAccessCode == accessCode); var appUser = _users.SingleOrDefault(n => accessKey != null && n.AppUserId == accessKey.AppUserId); if (appUser != null) { if (appUser.Status == UserStatus.Inactive.ToString()) { //update user var response = await new AppUserFactory().ActivateUser(new AppConfig().ActivateAccountUrl, appUser.AppUserId); if (response.AppUser != null) { //display notification TempData["display"] = "You have successfully verified your account, Login and Enjoy the Experience!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Login", "Account")); } //display notification TempData["display"] = "There was an issue Activating your Account Try again or Contact Camerack Support!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(RedirectToAction("Login", "Account")); } if (appUser.Status == UserStatus.Active.ToString()) { //display notification TempData["display"] = "You have already activated your account, use your username and password to login!"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(RedirectToAction("Login", "Account")); } } //display notification TempData["display"] = "Your Reuqest is Invalid, Try again Later!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(RedirectToAction("Login", "Account")); }
public ActionResult ForgotPassword(AccountModel model) { try { //populate object and save transaction var response = new AppUserFactory().PasswordReset(new AppConfig().ResetPasswordUrl, model).Result; //display notification TempData["display"] = response.AccessLog.Message; TempData["notificationtype"] = NotificationType.Error.ToString(); return(RedirectToAction("Login")); } catch (Exception ex) { //display notification TempData["display"] = ex.ToString(); TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(model)); } }
public ActionResult UserBank() { var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId")); var userBank = _databaseConnection.UserBanks.SingleOrDefault(n => n.CreatedBy == signedInUserId); var banks = new AppUserFactory().GetAllBanks(new AppConfig().AllBanks).Result; if (userBank != null && userBank.BankId != null) { ViewBag.BankId = new SelectList( banks, "BankId", "Name", userBank.BankId); } else { ViewBag.BankId = new SelectList( banks, "BankId", "Name"); } return(View(userBank)); }
public ActionResult ChangePassword(AccountModel model) { try { var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId")); var userString = HttpContext.Session.GetString("StudioLoggedInUser"); var appUser = JsonConvert.DeserializeObject <AppUser>(userString); if (appUser != null) { appUser.Password = model.Password; appUser.Password = appUser.Password; appUser.LastModifiedBy = signedInUserId; appUser.DateLastModified = DateTime.Now; } var resonse = new AppUserFactory().ChangePassword(new AppConfig().ChangePasswordrl, appUser); if (resonse.Result.AppUser == null) { //display notification TempData["display"] = resonse.Result.AccessLog.Message; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(model)); } var newUserString = JsonConvert.SerializeObject(resonse.Result.AppUser); HttpContext.Session.SetString("StudioLoggedInUser", newUserString); //display notification TempData["display"] = resonse.Result.AccessLog.Message; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Profile")); } catch (Exception ex) { //display notification TempData["display"] = ex.ToString(); TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(model)); } }
public AppUserEntity GetAppUser(string username) { // find the id associated with username try { Guid userId = checkNetDbContext.AspnetUsers.Where(u => u.UserName == username.Trim()).FirstOrDefault().UserId; AspnetAppUsers aspnetAppUserModel = checkNetDbContext.AspnetAppUsers.Find(userId); // find the appuser with this id and construct entity AppUserEntity appUserEntity = AppUserFactory.Create(aspnetAppUserModel.UserId, aspnetAppUserModel.FkAspnetAppCustomersCustNo , aspnetAppUserModel.CurrentUserProviderKey, aspnetAppUserModel.SelectedFileGroup, aspnetAppUserModel.SelectedFileGuid , aspnetAppUserModel.StatusCode, aspnetAppUserModel.EmailAddress, aspnetAppUserModel.FirstName, aspnetAppUserModel.LastName , aspnetAppUserModel.ReceiveStatusEmails, aspnetAppUserModel.ExportType, aspnetAppUserModel.LastUpdatedBy , aspnetAppUserModel.LastUpdateDate, aspnetAppUserModel.FileUploadMode); return(appUserEntity); }catch (NullReferenceException e) { return(null); } }
public IActionResult Photographers() { try { var users = new AppUserFactory().GetAllUsers(new AppConfig().FetchUsersUrl) .Result.Where(n => n.RoleId == 3); var results = (from a in users join b in _databaseConnection.Images.ToList() on a.AppUserId equals b.AppUserId where b != null select a).Distinct().ToList(); return(View(results)); } catch (Exception) { //display notification TempData["display"] = "An error ocurred while fetching your orders check your internet connectivity and try again!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View()); } }
public async Task <JsonResult> SaveImageAction([FromBody] ImageAction action) { var actionExist = _databaseConnection.ImageActions.Where( n => n.AppUserId == action.AppUserId && n.ImageId == action.ImageId).ToList(); if (actionExist.Count <= 0) { _databaseConnection.Add(action); _databaseConnection.SaveChanges(); var image = _databaseConnection.Images.SingleOrDefault(n => n.ImageId == action.ImageId); if (image != null) { var notification = new PushNotification { AppUserId = action.OwnerId, CreatedBy = action.AppUserId, LastModifiedBy = action.AppUserId, DateLastModified = DateTime.Now, DateCreated = DateTime.Now, Category = SystemNotificationCategory.Comment.ToString(), Read = false, ControllerId = image.ImageId, ClientId = 4 }; var singleOrDefault = new AppUserFactory() .GetAllUsers(new AppConfig().FetchUsersUrl).Result .SingleOrDefault(n => n.AppUserId == image.AppUserId); if (singleOrDefault != null) { notification.Message = singleOrDefault.Name + " Rated your Image"; } await new AppUserFactory().SavePushNotification(new AppConfig().SavePushNotifications, notification); } } return(Json(action)); }
public async Task <JsonResult> SaveComment([FromBody] ImageComment comment) { _databaseConnection.Add(comment); _databaseConnection.SaveChanges(); var image = _databaseConnection.Images.SingleOrDefault(n => n.ImageId == comment.ImageId); if (comment.ImageCommentId > 0) { if (image != null) { var notification = new PushNotification { AppUserId = image.AppUserId, CreatedBy = comment.CreatedBy, LastModifiedBy = comment.CreatedBy, DateLastModified = DateTime.Now, DateCreated = DateTime.Now, Category = SystemNotificationCategory.Comment.ToString(), Read = false, ControllerId = image.ImageId, ClientId = 4 }; var singleOrDefault = new AppUserFactory() .GetAllUsers(new AppConfig().FetchUsersUrl).Result .SingleOrDefault(n => n.AppUserId == image.AppUserId); if (singleOrDefault != null) { notification.Message = singleOrDefault.Name + " Commented on your Image"; } await new AppUserFactory().SavePushNotification(new AppConfig().SavePushNotifications, notification); } } return(Json(comment)); }
public IActionResult Newsletter(UserEmail email) { List <AppUser> users = new List <AppUser>(); var subscriptions = new AppUserFactory().GetAllSubscriptions(new AppConfig().GetSubscriptionsUrl) .Result.Where(n => n.Status == "Active").ToList(); foreach (var item in subscriptions) { AppUser user = new AppUser { Name = item.Name, Email = item.Email }; users.Add(user); } email.MessageCategory = "Newsletter"; email.AppUsers = users; new SendUserMessage().SendNewsLetter(email); TempData["display"] = "You have successfully sent the Newsletter!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Dashboard", "Home")); }
public ActionResult ForgotPassword(FormCollection collectedValues) { if (ModelState.IsValid) { var userId = new AppUserFactory().GetAppUserByEmail(collectedValues["Email"].Trim()).AppUserId; var passwordReset = new PasswordReset(); var token = Membership.GeneratePassword(8, 0); passwordReset.ExpiryDate = DateTime.Now.AddMinutes(2); passwordReset.AppUserId = userId; passwordReset.Token = token; _dbc.PasswordResets.Add(passwordReset); _dbc.SaveChanges(); var user = _db.AppUsers.Find(userId); user.Token = token; Session["token"] = token; _db.Entry(user).State = EntityState.Modified; _db.SaveChanges(); new AuthenticationFactory().ForgotPasswordRequest(collectedValues["Email"].Trim()); return(RedirectToAction("Login")); } return(View()); }
public async Task <ActionResult> ForgotPassword(string accessCode) { var model = new AccountModel(); var accessKey = new AppUserFactory().GetUsersAccessKey(new AppConfig().FetchUsersAccessKeys) .Result.SingleOrDefault(n => n.PasswordAccessCode == accessCode); if (accessKey != null) { if (DateTime.Now > accessKey.ExpiryDate) { //display notification TempData["display"] = "This link has already expired, Reset the password again!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(RedirectToAction("Login", "Account")); } var user = _users.SingleOrDefault(n => n.AppUserId == accessKey.AppUserId); if (user != null) { model.Email = user.Email; model.Username = user.Username; model.ClientId = new AppConfig().ClientId; model.LoginName = user.Email; } //update accessKeys if (user != null) { await new AppUserFactory().UpdatePasswordAccessKey(new AppConfig().UpdatePasswordAccessKey, user.AppUserId); } return(View(model)); } //display notification TempData["display"] = "This link is not genuine!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(RedirectToAction("Login")); }
public ActionResult EditProfile(AppUser appUser, IFormCollection collection) { try { //populate object and save transaction var signedInUserId = Convert.ToInt64(HttpContext.Session.GetString("StudioLoggedInUserId")); appUser.LastModifiedBy = signedInUserId; appUser.DateLastModified = DateTime.Now; appUser.ClientId = new AppConfig().ClientId; appUser.Biography = collection["Biography"]; var resonse = new AppUserFactory().EditProfile(new AppConfig().EditProfileUrl, appUser); if (resonse.Result.AppUser == null) { //display notification TempData["display"] = resonse.Result.AccessLog.Message; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(appUser)); } var userString = JsonConvert.SerializeObject(resonse.Result.AppUser); HttpContext.Session.SetString("StudioLoggedInUser", userString); //display notification TempData["display"] = resonse.Result.AccessLog.Message; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Profile")); } catch (Exception) { //display notification TempData["display"] = "You are unable to update your profile, Check and Try again!"; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(appUser)); } }
public JtwTokenFactory(ISecurityKeyFactory securityKeyFactory, UserManager <AppUser> userManager, AppUserFactory appUserFactory) { _securityKeyFactory = securityKeyFactory; _userManager = userManager; _appUserFactory = appUserFactory; }
public async Task <ActionResult> RejectImage(IFormCollection collection) { var id = Convert.ToInt64(collection["ImageId"]); var image = _databaseConnection.Images.Find(id); //customize user object to sent email to user var appUser = new AppUserFactory().GetAllUsers(new AppConfig().FetchUsersUrl) .Result.Single(n => n.AppUserId == image.AppUserId); appUser.Biography = collection["Reason"]; appUser.DateCreated = image.DateCreated; appUser.Address = image.Title; //upload image via Cloudinary API Call var account = new Account( new AppConfig().CloudinaryAccoutnName, new AppConfig().CloudinaryApiKey, new AppConfig().CloudinaryApiSecret); var cloudinary = new Cloudinary(account); var delParams = new DelResParams { PublicIds = new List <string> { image.FileName }, Invalidate = true }; await cloudinary.DeleteResourcesAsync(delParams); var tags = _databaseConnection.ImageTags.Where(n => n.ImageId == image.ImageId); foreach (var item in tags) { _databaseConnection.ImageTags.RemoveRange(item); } var imageActions = _databaseConnection.ImageActions.Where(n => n.ImageId == image.ImageId); foreach (var item in imageActions) { _databaseConnection.ImageActions.RemoveRange(item); } var imageComments = _databaseConnection.ImageComments.Where(n => n.ImageId == image.ImageId); foreach (var item in imageComments) { _databaseConnection.ImageComments.RemoveRange(item); } var imageReports = _databaseConnection.ImageReports.Where(n => n.ImageId == image.ImageId); foreach (var item in imageReports) { _databaseConnection.ImageReports.RemoveRange(item); } _databaseConnection.Images.Remove(image); _databaseConnection.SaveChanges(); //display notification TempData["display"] = "You have successfully removed the image from the platform!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); }
public ActionResult ResetPassword(int Id) { var user = new AppUserFactory().GetAppUserById(Id); return(View(user)); }
public ActionResult Register([Bind(Include = "Firstname,Lastname,Email,Mobile,Password")] AppUser appUser, FormCollection collectedValues) { var loggedinuser = Session["bhuinfologgedinuser"] as AppUser; HttpPostedFileBase profileImage = Request.Files["avatar-2"]; if (ModelState.IsValid) { if (collectedValues["student"] == null) { if ((loggedinuser != null) && (loggedinuser.Role == UserType.Administrator.ToString())) { appUser.DateCreated = DateTime.Now; appUser.DateLastModified = DateTime.Now; appUser.CreatedById = loggedinuser.AppUserId; appUser.LastModifiedById = loggedinuser.AppUserId; appUser.Role = typeof(UserType).GetEnumName(int.Parse(collectedValues["Role"])); var password = Membership.GeneratePassword(8, 1); var hashPassword = new Md5Ecryption().ConvertStringToMd5Hash(password.Trim()); appUser.Password = new RemoveCharacters().RemoveSpecialCharacters(hashPassword); appUser.AppUserImage = new FileUploader().UploadFile(profileImage, UploadType.ProfileImage); var userExist = new AppUserFactory().CheckIfStudentUserExist(appUser.Email.Trim(), appUser.MatricNumber.Trim()); if (userExist) { TempData["user"] = "******"; TempData["notificationtype"] = NotificationType.Danger.ToString(); return(View(appUser)); } _db.AppUsers.Add(appUser); _db.SaveChanges(); TempData["user"] = "******"; TempData["notificationtype"] = NotificationType.Success.ToString(); appUser.Password = password; new MailerDaemon().NewUser(appUser); } else { TempData["user"] = "******"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(RedirectToAction("Index")); } } else { appUser.DateCreated = DateTime.Now; appUser.DateLastModified = DateTime.Now; appUser.CreatedById = 1; appUser.MatricNumber = collectedValues["MatricNumber"].Trim(); appUser.LastModifiedById = 1; appUser.Role = UserType.Student.ToString(); var password = Membership.GeneratePassword(8, 1); var hashPassword = new Md5Ecryption().ConvertStringToMd5Hash(password.Trim()); appUser.AppUserImage = new FileUploader().UploadFile(profileImage, UploadType.ProfileImage); appUser.Password = new RemoveCharacters().RemoveSpecialCharacters(hashPassword); var userExist = new AppUserFactory().CheckIfGeneralUserExist(appUser.Email.Trim()); if (userExist) { TempData["student"] = "This user email already exist,try a different email!"; TempData["notificationtype"] = NotificationType.Danger.ToString(); return(View(appUser)); } _db.AppUsers.Add(appUser); _db.SaveChanges(); TempData["student"] = "You have been created on bhuinfo!"; TempData["notificationtype"] = NotificationType.Success.ToString(); appUser.Password = password; new MailerDaemon().NewUser(appUser); return(RedirectToAction("Login", "Account")); } return(RedirectToAction("Login", "Account")); } return(View(appUser)); }
public ActionResult Register(AccountModel model, IFormCollection collection) { try { var appUser = new AppUser { Name = model.Username, Mobile = model.Mobile, Email = model.Email, Username = model.Username, Status = UserStatus.Inactive.ToString(), ProfilePicture = "Avatar.jpg", BackgroundPicture = "photo1.jpg", DateCreated = DateTime.Now, DateLastModified = DateTime.Now, RoleId = 3, ClientId = new AppConfig().ClientId, Password = model.Password, ConfirmPassword = model.ConfirmPassword }; //post user object and get response var response = new AppUserFactory() .RegisterUser(new AppConfig().RegisterUsersUrl, appUser).Result; //validate response if (response.AccessLog.Status == "Denied") { //display notification TempData["display"] = response.AccessLog.Message; TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(model)); } if (response.AppUser != null) { appUser = response.AppUser; //populate and save bank transaction var userBank = new UserBank { CreatedBy = appUser.AppUserId, LastModifiedBy = appUser.AppUserId, DateCreated = DateTime.Now, DateLastModified = DateTime.Now }; _databaseConnection.UserBanks.Add(userBank); _databaseConnection.SaveChanges(); //display notification TempData["display"] = response.AccessLog.Message; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Login")); } //display notification TempData["display"] = "This Request is Unavailable, Try again Later"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Login")); } catch (Exception ex) { //display notification TempData["display"] = ex.ToString(); TempData["notificationtype"] = NotificationType.Error.ToString(); return(View(model)); } }