i was trying to create a simple service for login. but the value is not getting in respository class. i think i miss some code..can anyone help me ..? thanks in advance.
here is my code for controller
- static LoginRespository repository = new LoginRespository();
- public string AddEmployees(Login Emp)
- {
- var response = repository.AddEmployees(Emp);
- return response;
-
- }
and respository class here
- public string AddEmployees(Login Emp)
- {
-
- SqlCommand com;
- SqlConnection con = new SqlConnection(@"Data Source=DOTNET;Initial Catalog=edin;Integrated Security=True;Pooling=False");
- try
- {
- com = new SqlCommand("select * from data where name='" + Emp.username + "'", con);
- con.Open();
- SqlDataReader dr = com.ExecuteReader();
- if (dr.HasRows)
- {
- return "success";
- }
- else
- {
- return "error";
- }
- con.Close();
- }
- catch (Exception aa)
- {
- return aa.ToString();
- }
- }
and my model class
- public string username { get; set; }
- public string password { get; set; }
can anyone tell what mistake i have made..