public ActionResult GetEmployees()
        {
            EmployeesFinance            employees = Manager.Instance().GetEmployeesFinance();
            List <EmployeeFinanceModel> Salaries  = Manager.Instance().CastToEmployeesFinanceModel(employees);
            List <EmployeeFinanceModel> Employees = new List <EmployeeFinanceModel>();

            foreach (EmployeeFinanceModel emp in Salaries)
            {
                bool exists = false;
                foreach (var item in Employees)
                {
                    if (item.Id == emp.Id)
                    {
                        exists = true;
                        break;
                    }
                }
                if (!exists)
                {
                    Employees.Add(emp);
                }
            }
            List <EmployeeFinanceModel> SortedList = Employees.OrderBy(e => e.Name).ToList();

            return(View(SortedList));
        }
        public EmployeesFinance GetEmployeeFinance()
        {
            EmployeesFinance employees = new EmployeesFinance();

            using (SqlConnection con = new SqlConnection
                                           (ConfigurationManager.ConnectionStrings["SQLProviderConnectionString"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("dbo.GetSalaries", con);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    EmployeeFinance employee = new EmployeeFinance();
                    employee.Id       = Int32.Parse(reader[0].ToString());
                    employee.Name     = reader[1].ToString();
                    employee.LastName = reader[2].ToString();
                    int e = 0;
                    Int32.TryParse(reader[3].ToString(), out e);
                    employee.Salary = e;
                    DateTime d;
                    DateTime.TryParse(reader[4].ToString(), out d);
                    employee.SalaryDate = d;
                    employees.Employees.Add(employee);
                }
            }
            return(employees);
        }
Ejemplo n.º 3
0
        public EmployeesFinance GetEmployeesFinance()
        {
            EmployeesFinance deserialized = new EmployeesFinance();
            string           baseUrl      = ConfigurationManager.ConnectionStrings["FinanceServerName"].ConnectionString;
            string           url          = baseUrl + DestinationNames.GetFinanceEmployees;

            deserialized = Communicator.GetEntitiesList <EmployeesFinance>(url);
            return(deserialized);
        }
        public byte[] SerializeEmployeeFinance()
        {
            EmployeesFinance employees    = this.GetEmployeesFinance();
            MemoryStream     memorystream = new MemoryStream();
            BinaryFormatter  bf           = new BinaryFormatter();

            bf.Serialize(memorystream, employees);
            memorystream.Flush();
            memorystream.Position = 0;
            byte[] Bytes = memorystream.ToArray();
            return(Bytes);
        }
Ejemplo n.º 5
0
        public List <EmployeeFinanceModel> CastToEmployeesFinanceModel(EmployeesFinance employees)
        {
            List <EmployeeFinanceModel> Salaries = new List <EmployeeFinanceModel>();

            foreach (EmployeeFinance employee in employees.Employees)
            {
                EmployeeFinanceModel emp = new EmployeeFinanceModel();
                emp.Id         = employee.Id;
                emp.Name       = employee.Name;
                emp.LastName   = employee.LastName;
                emp.Salary     = employee.Salary;
                emp.SalaryDate = employee.SalaryDate;
                Salaries.Add(emp);
            }
            return(Salaries);
        }
Ejemplo n.º 6
0
        public EmployeesFinance GetEmployeeFinance()
        {
            EmployeesFinance employees = new EmployeesFinance();
            EmployeeFinance  employee1 = new EmployeeFinance();

            employee1.Id     = 1;
            employee1.Name   = "Jane";
            employee1.Salary = 2000;
            employees.Employees.Add(employee1);

            EmployeeFinance employee2 = new EmployeeFinance();

            employee2.Id     = 2;
            employee2.Name   = "Jack";
            employee2.Salary = 1000;
            employees.Employees.Add(employee2);
            return(employees);
        }
        public ActionResult SalaryChart(int Id)
        {
            EmployeesFinance            Employees = Manager.Instance().GetEmployeesFinance();
            List <EmployeeFinanceModel> Salaries  = Manager.Instance().CastToEmployeesFinanceModel(Employees);
            List <SalaryChartModel>     empl      = new List <SalaryChartModel>();

            for (int i = Salaries.Count() - 1; i >= 0; --i)
            {
                if (Salaries[i].Id == Id)
                {
                    SalaryChartModel e = new SalaryChartModel();
                    e.Salary = Salaries[i].Salary;
                    e.date   = Salaries[i].SalaryDate;
                    empl.Add(e);
                }
            }
            return(View(empl));
        }
        public EmployeesFinance GetEmployeesFinance()
        {
            EmployeesFinance deserialized = new EmployeesFinance();
            string           baseUrl      = ConfigurationManager.ConnectionStrings["DALServerName"].ConnectionString;
            string           url          = baseUrl + DestinationNames.GetEmployees;
            HttpWebRequest   request      = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "GET";

            WebResponse response = request.GetResponse();

            using (Stream stream = response.GetResponseStream())
            {
                MemoryStream memStr = new MemoryStream();
                stream.CopyTo(memStr);
                memStr.Flush();
                memStr.Position = 0;
                BinaryFormatter bfd = new BinaryFormatter();
                deserialized = bfd.Deserialize(memStr) as EmployeesFinance;
            }
            return(deserialized);
        }