Ejemplo n.º 1
0
        private async Task <Report> CreateReport(int year, int month)
        {
            Report report = new Report(year, month);
            IEnumerable <Department> activeDeps = await _departmentRepository.GetActiveAsync();

            foreach (var dep in activeDeps)
            {
                var depblock = new DepartmentReportBlock(dep.Name);
                IEnumerable <Employee> emps = await _employeeRepository.FindAllByDepartmentAsync(dep.Id);

                foreach (var emp in emps)
                {
                    var empBlock = new EmployeeReportBlock()
                    {
                        Name = emp.Name,
                        Inn  = emp.Inn
                    };
                    empBlock.BuhCode = await EmpCodeResolver.GetCode(emp.Inn);

                    empBlock.Salary = EmpSalaryService.Salary(empBlock);
                    depblock.AddEmployee(empBlock);
                }
                report.AddDepartmentBlocks(depblock);
            }
            return(report);
        }
Ejemplo n.º 2
0
 public void AddEmployee(EmployeeReportBlock emp)
 {
     if (emp == null)
     {
         return;
     }
     Employees.Add(emp);
 }
        public int Salary(EmployeeReportBlock employee)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://salary.local/api/empcode/" + employee.Inn);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(new { employee.BuhCode });
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            var    reader       = new System.IO.StreamReader(httpResponse.GetResponseStream(), true);
            string responseText = reader.ReadToEnd();

            return((int)Decimal.Parse(responseText));
        }
Ejemplo n.º 4
0
 private void ExportBlock(EmployeeReportBlock block)
 {
     _sb.AppendLine($"{block.Name} {block.Salary}р");
 }