Edison Augusthy

Edison Augusthy

  • NA
  • 52
  • 6.7k

not passing values

Oct 27 2016 1:39 AM
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
  1. static LoginRespository repository = new LoginRespository();  

  2.         public string AddEmployees(Login Emp)  
  3.         {  
  4.             var response = repository.AddEmployees(Emp);  
  5.             return response;  
  6.   
  7.         }  
and respository class here
  1. public string AddEmployees(Login Emp)  
  2.        {  
  3.             
  4.            SqlCommand com;  
  5.            SqlConnection con = new SqlConnection(@"Data Source=DOTNET;Initial Catalog=edin;Integrated Security=True;Pooling=False");  
  6.            try  
  7.            {  
  8.                com = new SqlCommand("select * from data where name='" + Emp.username + "'", con);  
  9.                con.Open();  
  10.                SqlDataReader dr = com.ExecuteReader();  
  11.                if (dr.HasRows)  
  12.                {  
  13.                    return "success";  
  14.                }  
  15.                else  
  16.                {  
  17.                    return "error";  
  18.                }  
  19.                con.Close();  
  20.            }  
  21.            catch (Exception aa)  
  22.            {  
  23.                return aa.ToString();  
  24.            }  
  25.        }  
and my model class
  1. public string username { get; set; }  
  2. public string password { get; set; }  
 can anyone tell what mistake i have made..

Answers (2)