Ejemplo n.º 1
0
 /// <summary>
 /// Casts DataModel entity to MVC Model entity
 /// </summary>
 /// <param name="employee"></param>
 private EmployeeManagementModel CastToCommonEmployeeModel(DataModel.Entities.Common.Employee employee)
 {
     return(new EmployeeManagementModel()
     {
         Id = employee.Id,
         Name = employee.Name,
         Surname = employee.LastName
     });
 }
Ejemplo n.º 2
0
        public List <DataModel.Entities.Common.Employee> GetEmployees()
        {
            List <DataModel.Entities.Common.Employee> deserialized = new List <DataModel.Entities.Common.Employee>();
            string baseUrl = ConfigurationManager.ConnectionStrings["ManagementServerName"].ConnectionString;
            string url     = baseUrl + DestinationNames.GetTaskEmployees;

            deserialized = Communicator.GetEntities <DataModel.Entities.Common.Employee>(url);
            List <DataModel.Entities.Common.Employee> employees = new List <DataModel.Entities.Common.Employee>();

            foreach (var item in deserialized)
            {
                DataModel.Entities.Common.Employee employee = new DataModel.Entities.Common.Employee();
                employee.Id   = item.Id;
                employee.Name = item.Name;
                employees.Add(employee);
            }
            return(employees);
        }
        public List <DataModel.Entities.Common.Employee> GetEmployees()
        {
            List <DataModel.Entities.Common.Employee> employees = new List <DataModel.Entities.Common.Employee>();

            using (SqlConnection con = new SqlConnection
                                           (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("dbo.GetEmployees", con);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    DataModel.Entities.Common.Employee employee = new DataModel.Entities.Common.Employee();
                    employee.Id       = Int32.Parse(reader[0].ToString());
                    employee.Name     = reader[1].ToString();
                    employee.LastName = reader[1].ToString();
                    employees.Add(employee);
                }
                return(employees);
            }
        }