public async Task <ActionResult> Index(HireThingsUser model, long ddlCountry, long ddlLocation, long[] groupListbox, CancellationToken cancellationToken) { model.CountryId = ddlCountry; model.LocationId = ddlLocation; ModelState.Remove("CountryId"); ModelState.Add("CountryId", new ModelState()); ModelState.SetModelValue("CountryId", new ValueProviderResult(model.CountryId, model.CountryId.ToString(), null)); ModelState.Remove("LocationId"); ModelState.Add("LocationId", new ModelState()); ModelState.SetModelValue("LocationId", new ValueProviderResult(model.LocationId, model.LocationId.ToString(), null)); ModelState.Remove("Pin"); ModelState.Remove("ConfirmPin"); if (!ModelState.IsValid) { ViewData[Constant.CustomSuccessMessage] = Constant.CustomValidationErrorMessage; ViewData[Constant.QuerySuccess] = false; model = (HireThingsUser)await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, GetCanellationToken(cancellationToken)); return(View(model)); } ModelState.Clear(); model = (HireThingsUser)await _service.SaveAsync(HttpContext.ApplicationInstance.Context, model, GetCanellationToken(cancellationToken)); ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess]; ViewData[Constant.FormTitle] = HttpContext.Items[Constant.FormTitle]; if (Convert.ToBoolean(ViewData[Constant.QuerySuccess])) { ViewData[Constant.FormTitle] = "Edit User"; } return(View(model)); }
public async Task <IHireThingsUser> IndexAsync(System.Web.HttpContext context, IHireThingsUser model, CancellationToken cancellationToken) { if (model == null) { model = new HireThingsUser(); } model = await PopulateInitialValuesAsync(model, cancellationToken); return(model); }
public Task <IHireThingsUser> FindByNameAsync(string Email) { TempUserDAL dal = new TempUserDAL(); IHireThingsUser user = new HireThingsUser() { UserName = Email }; user = dal.Select(user); return(Task.FromResult <IHireThingsUser>(user)); }
public async Task <IHireThingsUser> IndexPublicAsync(System.Web.HttpContext context, CancellationToken cancellationToken) { IHireThingsUser model = new HireThingsUser() { UserId = userId, IsActive = true, RoleId = 0 }; model = await PopulateInitialValuesAsync(model, cancellationToken); return(model); }
public async override Task <IHireThingsUser> IndexAsync(System.Web.HttpContext context, CancellationToken cancellationToken) { IHireThingsUser model = new HireThingsUser() { UserId = userId }; model = await PopulateInitialValuesAsync(model, cancellationToken); return(model); }
public async override Task <IHireThingsUser> SelectByIDAsync(long id, long userId, CancellationToken cancellationToken) { DataTable dt = null; Dictionary <string, object> param = new Dictionary <string, object>(); IHireThingsUser user = null; param.Add(DBObjects.SPParameter.UserId, GetParameter(DBObjects.SPParameter.UserId, ParameterDirection.Input, ((int)SqlDbType.BigInt), 8, id)); dt = await this.GetSPDataTableAsync(DBObjects.StoredProcedures.pspSelectUserById.ToString(), cancellationToken, param); if (dt != null && dt.Rows.Count > 0) { user = new HireThingsUser(); user.RoleId = Convert.ToInt64(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["RoleId"])); user.EmailId = Convert.ToString(dt.Rows[0]["EmailId"]); user.ConfirmEmailId = Convert.ToString(dt.Rows[0]["EmailId"]); user.UserName = Convert.ToString(dt.Rows[0]["UserName"]); user.FirstName = Convert.ToString(dt.Rows[0]["FirstName"]); user.MiddleName = Convert.ToString(dt.Rows[0]["MiddleName"]); user.LastName = Convert.ToString(dt.Rows[0]["LastName"]); user.CountryId = Convert.ToInt64(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["CountryId"])); user.LocationId = Convert.ToInt64(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["LocationId"])); user.RoleName = Convert.ToString(dt.Rows[0]["RoleName"]); user.GenderId = Convert.ToInt64(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["GenderId"])); user.DOB = Convert.ToDateTime(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["DOB"])); user.PhoneNo = Convert.ToString(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["PhoneNo"])); user.Address1 = Convert.ToString(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["Address1"])); user.Address2 = Convert.ToString(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["Address2"])); user.Address3 = Convert.ToString(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["Address3"])); user.SecurityQuestionID = Convert.ToInt64(PublicFunctions.ConvertDBNullToNull(dt.Rows[0]["SecurityQuestionID"])); user.SecurityAnswer = "***"; user.Id = dt.Rows[0]["UserId"].ToString(); user.RoleId = Convert.ToInt64(dt.Rows[0]["RoleId"]); user.PINHash = dt.Rows[0]["PINHash"].ToString(); user.IsEmailConfirmed = Convert.ToBoolean(dt.Rows[0]["IsEmailConfirmed"]); user.IsActive = Convert.ToBoolean(dt.Rows[0]["IsActive"]); } return(user); }
public async Task <ActionResult> ProfileSettings(HireThingsUser model, CancellationToken cancellationToken) { TempUserDAL _dal = new TempUserDAL(); ModelState.Remove("Pin"); ModelState.Remove("ConfirmPin"); ModelState.Remove("SecurityQuestionId"); ModelState.Remove("SecurityAnswer"); ModelState.Remove("ConfirmEmailId"); if (ModelState.IsValid) { model.Id = User.Identity.GetUserId(); await _service.ProfileUpdateAsync(this.HttpContext.ApplicationInstance.Context, model, GetCanellationToken(cancellationToken)); ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess]; return(View(model)); } // If ModelState.IsValid = False return(RedirectToAction("Index?cancellationToken =" + cancellationToken)); }
public async Task <ActionResult> PublicRegister(HireThingsUser model, long ddlCountry, long ddlLocation, long[] groupListbox, CancellationToken cancellationToken) { model.CountryId = ddlCountry; model.LocationId = ddlLocation; ModelState.Remove("CountryId"); ModelState.Add("CountryId", new ModelState()); ModelState.SetModelValue("CountryId", new ValueProviderResult(model.CountryId, model.CountryId.ToString(), null)); ModelState.Remove("LocationId"); ModelState.Add("LocationId", new ModelState()); ModelState.SetModelValue("LocationId", new ValueProviderResult(model.LocationId, model.LocationId.ToString(), null)); ModelState.Remove("IsActive"); ModelState.Remove("RoleId"); if (ModelState.IsValid) { var user = model;; user.Pin = model.Pin; user.UserName = model.EmailId; // model.Id = "0"; var result = await _userManager.CreateAsync(user, model.Pin); if (result.Succeeded && user.Id != "0") { //temporary code return(Redirect("~/Account/Login")); // Comment the following line to prevent log in until the user is confirmed. // await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account"); string mName = ""; if (model.MiddleName != null) { mName = model.MiddleName.Trim(); } string Username = string.Format("{0}{1} {2}", model.FirstName.Trim(), (" " + mName).TrimEnd(), model.LastName.Trim()); try { long userId = Convert.ToInt64(user.Id); if (_service.sendEmail(this.HttpContext.ApplicationInstance.Context, model.EmailId, callbackUrl, new EmailServerModel() { UserName = Username }, Constant.EmailType.UserSignup, userId, user.CountryId)) { ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess]; ViewData[Constant.CustomSuccessMessage] = "User has been created successfully. An email has been sent to given email address"; return(RedirectToAction("PublicUserSignUpConfirmation")); } else { ViewData[Constant.QuerySuccess] = false; ViewData[Constant.CustomSuccessMessage] = "User has been created successfully. Email cannot be sent."; } } catch (Exception ex) { ViewData[Constant.QuerySuccess] = false; ViewData[Constant.CustomSuccessMessage] = "User has been created successfully. Email cannot be sent."; } } else { ViewData[Constant.QuerySuccess] = false; ViewData[Constant.CustomSuccessMessage] = "Error : Email is already associated with another user."; model.Id = string.Empty; AddErrors(result); } } else { ViewData[Constant.QuerySuccess] = false; ViewData[Constant.CustomSuccessMessage] = "Error : Some validations failed. Please check the error message for details."; } model = (HireThingsUser)await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, model, GetCanellationToken(cancellationToken)); return(View(model)); }