Example #1
0
        private static void Main()
        {
            // Db setup
            var db = new EmployeeDB();

            // Add some employees
            db.AddEmployee(new Employee("Anne", 3000, 51));
            db.AddEmployee(new Employee("Berit", 4000, 25));
            db.AddEmployee(new Employee("Christel", 1000, 37));

            // Setup compile
            var compiledDb      = new CompileDB(db);
            var reportGenerator = new ReportGenerator(compiledDb);

            //Default (name-first) report
            reportGenerator.GenerateReport();

            Console.WriteLine("");
            Console.WriteLine("");

            // Create a salary-first report
            reportGenerator.SetOutputFormat(ReportOutputFormatType.SalaryFirst);
            reportGenerator.GenerateReport();

            Console.WriteLine("");
            Console.WriteLine("");

            // Create an age-first report
            reportGenerator.SetOutputFormat(ReportOutputFormatType.AgeFirst);
            reportGenerator.GenerateReport();
            Console.ReadLine();
        }
Example #2
0
        static void Main()
        {
            // Initialize the database
            var db = new EmployeeDB();

            db.AddEmployee(new Employee("Iceman", 1000, 25));
            db.AddEmployee(new Employee("Goose", 2000, 30));
            db.AddEmployee(new Employee("Maverick", 3000, 35));
            db.AddEmployee(new Employee("Charlie", 1500, 22));

            // Initialize report generation
            var generation = new ReportGeneration(
                new NameFirstFormatting(),
                new DatabaseEmployeeStorage(db),
                new ConsoleRendition());

            var exitProgram = false;

            while (!exitProgram)
            {
                WriteLine("Select report output format ('q' to quit):");
                WriteLine(" [N]ame-first");
                WriteLine(" [S]alary-first");
                WriteLine(" [A]ge-first");

                switch (char.ToUpper(ReadKey(true).KeyChar))
                {
                case 'N':
                    generation.SetOutputFormat(new NameFirstFormatting());
                    generation.CompileReport();
                    break;

                case 'S':
                    generation.SetOutputFormat(new SalaryFirstFormatting());
                    generation.CompileReport();
                    break;

                case 'A':
                    generation.SetOutputFormat(new AgeFirstFormatting());
                    generation.CompileReport();
                    break;

                case 'Q':
                    exitProgram = true;
                    break;
                }
                WriteLine();
                WriteLine();
                WriteLine();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var db = new EmployeeDB();

            // Add some employees
            db.AddEmployee(new Employee("Anne", 3000, 10));
            db.AddEmployee(new Employee("Berit", 2000, 12));
            db.AddEmployee(new Employee("Christel", 1000, 4));

            var reportGenerator = new ReportGenerator(db);

            // Create a default (name-first) report
            reportGenerator.CompileReport();

            Console.WriteLine("");
            Console.WriteLine("");

            // Create a salary-first report
            reportGenerator.CompileReport();
        }
Example #4
0
        static void Main(string[] args)
        {
            var db = new EmployeeDB();

            // Add some employees
            db.AddEmployee(new Employee("Anne", 3000, 10));
            db.AddEmployee(new Employee("Berit", 2000, 12));
            db.AddEmployee(new Employee("Christel", 1000, 4));

            var reportGenerator = new ReportGenerator(db);

            // Create a default (name-first) report
            reportGenerator.CompileReport();

            Console.WriteLine("");
            Console.WriteLine("");

            // Create a salary-first report
            reportGenerator.CompileReport();
        }
Example #5
0
        static void Main(string[] args)
        {
            var db = new EmployeeDB();

            // Add some employees
            db.AddEmployee(new Employee("Anne", 3000));
            db.AddEmployee(new Employee("Berit", 2000));
            db.AddEmployee(new Employee("Christel", 1000));

            var reportGenerator = new ReportGenerator(db);

            // Create a default (name-first) report
            reportGenerator.CompileReport(ReportOutputFormatType.SalaryFirst);
            reportGenerator.printReport(new TerminalOutput());
            Console.WriteLine("");
            Console.WriteLine("");

            // Create a salary-first report
            // reportGenerator.SetOutputFormat(ReportOutputFormatType.SalaryFirst);
            // reportGenerator.CompileReport();
        }
 public ActionResult AddEmployee(Employee employee)
 {
     empDb.AddEmployee(employee);
     return(RedirectToAction("All"));
 }
Example #7
0
        public HttpResponseMessage AddEmployee([FromBody] EmployeeDataContext instanceDataModel)
        {
            try
            {
                if (instanceDataModel == null || instanceDataModel.language == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.EMPLOYEE_NULL_ERROR, data = Messages.EMPTY }));
                }

                string isValid = employeeValid.IsValidEmployee(instanceDataModel);
                if (ValedationClass.IsValidCompareToStrings(isValid, true.ToString()) == true)
                {
                    EmployeeData isDubleName = employeeDB.SearchByNameEmployee(instanceDataModel);
                    if (isDubleName != null)
                    {
                        if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.NAME_EN_IS_EXIST, data = Messages.EMPTY }));
                        }
                        else
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.NAME_IS_EXIST, data = Messages.EMPTY }));
                        }
                    }
                    else
                    {
                        EmployeeData isDublePhone = employeeDB.SearchByPhoneEmployee(instanceDataModel);
                        if (isDublePhone != null)
                        {
                            if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.PHONE_EN_IS_EXIST, data = Messages.EMPTY }));
                            }
                            else
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.PHONE_IS_EXIST, data = Messages.EMPTY }));
                            }
                        }
                        else
                        {
                            //Translation
                            employeeValid.Translation(instanceDataModel);
                            int isAdd = employeeDB.AddEmployee(instanceDataModel);
                            if (isAdd > 0)
                            {
                                if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_EN_MESSAGES, data = Messages.EMPTY }));
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.SUCCEDED_STATUS, msg = Messages.SUCCEDED_MESSAGES, data = Messages.EMPTY }));
                                }
                            }
                            else
                            {
                                if (ValedationClass.IsValidCompareToStrings(instanceDataModel.language.ToString(), Constants.LAN_EN) == true)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ADD_EMPLOYEE_EN_ERROR, data = Messages.EMPTY }));
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ADD_EMPLOYEE_ERROR, data = Messages.EMPTY }));
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = isValid, data = Messages.EMPTY }));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { status = Constants.FAILED_STATUS, msg = Messages.ADD_EMPLOYEE_ERROR, data = Messages.EMPTY }));
            }
        }