/// <summary> /// Метод возвращает хэш-код объекта. /// </summary> /// <returns>Хэш-код объекта.</returns> public override int GetHashCode() { return Cost.GetHashCode() + UsersEmail.GetHashCode() + PolicyDate.GetHashCode(); }
//public dynamic Postusers(dynamic data) public dynamic forgotPassword_email(users data) { List <string> errList = new List <string>(); if (!db.users.Any(o => o.email == data.email)) { errList.Add("emailNotExistErr"); return(JsonTool.toJson(errList)); } var user = (from p in db.users where p.email == data.email select p).SingleOrDefault(); int status = (int)user.status; if (status == -1) { errList.Add("userBannedErr"); return(JsonTool.toJson(errList)); } if (status == 0) { errList.Add("userNotActivateErr"); return(JsonTool.toJson(errList)); } //send reset password email string baseUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority); UsersEmail.sendResetPasswordEmail(user, baseUrl); return(JsonTool.toJson(user)); }
/// <summary>This method check Email exists or not</summary> /// <param name="usersEmail">The UsersEmail Object.</param> /// <returns>boolean Object.</returns> public bool CheckEmailExistsOrNot(UsersEmail usersEmail) { Logging.LogDebugMessage("Method: CheckEmailExistsOrNot, MethodType: Post, Layer: UserController, Parameters: UsersEmail = " + JsonConvert.SerializeObject(usersEmail)); using (UserBL userBL = new UserBL()) { return(userBL.CheckEmailExistsOrNot(usersEmail)); } }
/// <summary> /// Определяет, равны ли значения этого экземпляра и указанного объекта Insurance.BL.Models.Policy /// </summary> /// <param name="obj">Объект для сравнения с данным экземпляром.</param> /// <returns>true, если значение параметра obj совпадает со значением данного экземпляра; /// в противном случае — false. Если значением параметра obj является null, метод возвращает false.</returns> public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return false; } var policy = obj as Policy; return Cost.Equals(policy.Cost) && UsersEmail.Equals(policy.UsersEmail) && PolicyDate.Equals(policy.PolicyDate); }
/// <summary>This method check Email exists or not</summary> /// <param name="usersEmail">The UsersEmail Object.</param> /// <returns>boolean Object.</returns> public bool CheckEmailExistsOrNot(UsersEmail usersEmail) { Logging.LogDebugMessage("Method: CheckEmailExistsOrNot, MethodType: Post, Layer: UserDAL, Parameters: UsersEmail = " + JsonConvert.SerializeObject(usersEmail)); var dataSet = new DataSet(); bool isEmailExistsOrNot = false; try { using (var command = new SqlCommand()) { command.Connection = new SqlConnection(this.ConnectionString); command.CommandText = "USP_CheckEmailExistsOrNot"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter() { ParameterName = "@Email", Value = usersEmail.EmailAddress }); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(dataSet); if (dataSet != null) { isEmailExistsOrNot = Convert.ToBoolean(dataSet.Tables[0].Rows[0][0]); } } } } catch (SqlException sqlEx) { Logging.LogErrorMessage("Method: CheckEmailExistsOrNot, Layer: UserDAL, Stack Trace: " + sqlEx.ToString()); throw; } catch (Exception ex) { Logging.LogErrorMessage("Method: CheckEmailExistsOrNot, Layer: UserDAL, Stack Trace: " + ex.ToString()); throw; } return(isEmailExistsOrNot); }
/// <summary>This method check Email exists or not</summary> /// <param name="usersEmail">The UsersEmail Object.</param> /// <returns>boolean Object.</returns> public bool CheckEmailExistsOrNot(UsersEmail usersEmail) { Logging.LogDebugMessage("Method: CheckEmailExistsOrNot, MethodType: Post, Layer: UserBL, Parameters: UsersEmail = " + JsonConvert.SerializeObject(usersEmail)); using (UserDAL deleteUserrole = new UserDAL()) { try { return(deleteUserrole.CheckEmailExistsOrNot(usersEmail)); } catch (SqlException sqlEx) { Logging.LogErrorMessage("Method: CheckEmailExistsOrNot, Layer: UserBL, Stack Trace: " + sqlEx.ToString()); throw; } catch (Exception ex) { Logging.LogErrorMessage("Method: CheckEmailExistsOrNot, Layer: UserBL, Stack Trace: " + ex.ToString()); throw; } } }
public dynamic userRegister(FormUsersRegister data) { List <string> errList = new List <string>(); foreach (ModelState modelState in ModelState.Values) { foreach (ModelError error in modelState.Errors) { errList.Add(error.ErrorMessage.ToString()); } } if (db.users.Any(o => o.email == data.email)) { errList.Add("emailExistErr"); } if (db.users.Any(o => o.nickname == data.nickname)) { errList.Add("nicknameExistErr"); } if (errList.Count > 0) { return(JsonTool.toJson(errList)); } users newOne = new users { email = data.email, nickname = data.nickname, password = HashTool.getHash(data.password), gender = data.gender, birthDate = DateTime.ParseExact(data.birthDate.Replace("-", "/"), "yyyy/MM/dd", CultureInfo.InvariantCulture), createAt = DateTime.Now, updateAt = DateTime.Now }; if (UsersCmd.insert(newOne) <= 0) { errList.Add("dbInsertErr"); return(JsonTool.toJson(errList)); } ; newOne.userID = (from p in db.users where p.email == data.email select p).SingleOrDefault().userID; //send verify email string baseUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority); UsersEmail.sendValidateEmail(newOne, baseUrl); var obj = ( from p in db.users where p.userID == newOne.userID select new { p.userID, p.email, p.nickname, p.gender, p.birthDate, p.createAt } ).SingleOrDefault(); return(JsonTool.toJson(obj)); }