示例#1
0
        /// <summary>
        /// Gets all employee.
        /// </summary>
        /// <returns>ModelCL list</returns>
        public IEnumerable <ModelCL> GetAllEmployee()
        {
            IList <ModelCL> employees = new List <ModelCL>();

            using (connection)
            {
                SqlCommand command = new SqlCommand("spGetEmployee", connection);
                command.CommandType = CommandType.StoredProcedure;

                connection.Open();
                SqlDataReader dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    ModelCL model = new ModelCL();
                    model.Id              = (int)dataReader["Id"];
                    model.FirstName       = dataReader["Firstname"].ToString();
                    model.LastName        = dataReader["Lastname"].ToString();
                    model.Age             = dataReader["Age"].ToString();
                    model.Email           = dataReader["Email"].ToString();
                    model.EmployeeAddress = dataReader["EmployeeAddress"].ToString();

                    employees.Add(model);
                }
                connection.Close();
            }
            return(employees);
        }
示例#2
0
 public string UpdateEmployee(ModelCL model)
 {
     if (model != null)
     {
         return(employeeRL.UpdateEmployee(model));
     }
     else
     {
         return("Record is empty");
     }
 }
示例#3
0
 public string Register(ModelCL model)
 {
     if (model != null)
     {
         return(employeeRL.Register(model));
     }
     else
     {
         return("Record is empty");
     }
 }
示例#4
0
        /// <summary>
        /// Registers the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>string</returns>
        public string Register(ModelCL model)
        {
            using (connection)
            {
                SqlCommand command = new SqlCommand("spInsertEmployee", connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("FirstName", model.FirstName);
                command.Parameters.AddWithValue("LastName", model.LastName);
                command.Parameters.AddWithValue("Age", model.Age);
                command.Parameters.AddWithValue("Email", model.Email);
                command.Parameters.AddWithValue("EmployeeAddress", model.EmployeeAddress);
                connection.Open();
                int result = command.ExecuteNonQuery();
                if (result != 0)
                {
                    return(model.FirstName + "'s record Registered SuccessFully");
                }
                else
                {
                    return("Data is not Registered");
                }
            }
        }
示例#5
0
 public IActionResult UpdateEmployee(ModelCL model)
 {
     return(Ok(this.employeeBL.UpdateEmployee(model)));
 }
示例#6
0
 public IActionResult Register(ModelCL model)
 {
     return(Ok(this.employeeBL.Register(model)));
 }