private String ChecLoginModel(LoginModel model) { var result = String.Empty; if (model == null) { result = "Incorrect login or Password"; return result; } if (String.IsNullOrEmpty(model.Login)) { result = "Enter login please"; return result; } if (String.IsNullOrEmpty(model.Password)) { result = "Enter password please"; return result; } return result; }
public IHttpActionResult Login(LoginModel model) { var simpleValidationResult = ChecLoginModel(model); if (!String.IsNullOrEmpty(simpleValidationResult)) { return Ok(simpleValidationResult); } var userDto = Mapper.Map<UserDto>(model); if (_service.CheckUserCredentials(userDto)) { FormsAuthentication.SetAuthCookie(model.Login, true); return Ok(); } else { simpleValidationResult = "Incorrect login or Password"; return Ok(simpleValidationResult); } }