public IHttpActionResult SignupUsers(UsersSignupModel user) { try { if (String.IsNullOrEmpty(user.FirstName) || String.IsNullOrEmpty(user.LastName) || String.IsNullOrEmpty(user.Email) || String.IsNullOrEmpty(user.Password)) { string messageError = "Missing fields"; return(CustomResult(HttpStatusCode.BadRequest, new { message = messageError, errorCode = 400 })); } UsersSignupModel usersEmail = null; usersEmail = listUsers.Where(p => p.Email == user.Email).Select(p => p).FirstOrDefault(); if (usersEmail != null) { string messageError = "E-mail already exists"; return(CustomResult(HttpStatusCode.BadRequest, new { message = messageError, errorCode = 400 })); } if (!IsValid.IsValidEmail(user.Email)) { string messageError = "Invalid fields"; return(CustomResult(HttpStatusCode.BadRequest, new { message = messageError, errorCode = 400 })); } var userNumber = user.Phones.Select(q => q.Number).FirstOrDefault(); if (!IsValid.IsInteger(userNumber.ToString())) { string messageError = "Invalid fields"; return(CustomResult(HttpStatusCode.BadRequest, new { message = messageError, errorCode = 400 })); } user.created_at = DateTime.Now; listUsers.Add(user); string messageOK = "Subscribed User"; return(CustomResult(HttpStatusCode.OK, new { message = messageOK, })); } catch (Exception) { string messageError = "Invalid fields"; return(CustomResult(HttpStatusCode.ExpectationFailed, new { message = messageError, errorCode = 417 })); } }