Ejemplo n.º 1
0
        public async void GrabByImdbIds(string[] imdbIds)
        {
            List <Title> titles;

            titles = await _titleService.GetAllTitles();

            foreach (string imdbId in imdbIds)
            {
                try
                {
                    var exists = titles.Where(t => t.ImdbId == imdbId).Any();

                    if (exists)
                    {
                        continue;
                    }

                    Console.WriteLine($"Calling OMDb APi for '{imdbId}'");
                    _log.Info($"Calling OMDb APi for '{imdbId}'");

                    var title = _apiParser.GetTitleByImdbId(imdbId).Result;

                    if (!String.IsNullOrEmpty(title.Name))
                    {
                        Console.WriteLine($"Saving Title Name:'{title.Name}'  IMDb Id:'{imdbId}'");
                        _log.Info($"Saving Title Name:'{title.Name}'  IMDb Id:'{imdbId}'");
                        _titleService.AddTitle(title);
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.ToString());
                }
            }
        }
        private void buttonAddTitle_Click(object sender, EventArgs e)
        {
            Title title = new Title()
            {
                TitleName   = textAddTitleName.Text,
                Description = textAddTitleDescription.Text
            };

            _titleManager.AddTitle(title);
            MessageBox.Show("Title Eklendi ");
            ListMyTitles();
            ClearTitleTexts();
            FillTitleComboBoxes();
        }
Ejemplo n.º 3
0
 public ActionResult AddNewTitle(Title title)
 {
     if (!ModelState.IsValid)
     {
         ManiTitleViewModel model = new ManiTitleViewModel()
         {
             Title      = new Title(),
             ButtonName = "Add Title"
         };
         return(View(model));
     }
     _titleManager.AddTitle(title);
     TempData["message"] = "Yeni ünvan eklendi";
     return(RedirectToAction("TitleManiPage"));
 }
Ejemplo n.º 4
0
        public async Task <ActionResult> Create(Title title)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _titleService.AddTitle(title);

                    return(RedirectToAction("Index"));
                }

                var employees = Common.GetEmployees(_employeeService);
                ViewBag.EmployeeList = employees;
                return(View(title));
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    int    index   = ex.InnerException.Message.IndexOf("UC_");
                    string message = ex.InnerException.Message;
                    if (index > 0)
                    {
                        message = message.Substring(0, index - 1);
                    }
                    ModelState.AddModelError("Error", "There was an error during: " + message);
                }
                else
                {
                    ModelState.AddModelError("Error", "There was an error during: " + ex.ToString());
                }

                var employees = Common.GetEmployees(_employeeService);
                ViewBag.EmployeeList = employees;
                return(View(title));
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Generate()
        {
            var existingEmployess = await _employeeService.GetAll();

            if (existingEmployess.Count > 0)
            {
                return(View());
            }

            var daysGenerator = new RandomGenerator();

            string[] gender    = { "M", "F" };
            var      employees = Builder <Employee> .CreateListOfSize(10000)
                                 .All()
                                 .With(c => c.Ssn         = Faker.Identification.SocialSecurityNumber())
                                 .With(c => c.FirstName   = Faker.Name.First())
                                 .With(c => c.MiddleName  = Faker.Name.Middle())
                                 .With(c => c.LastName    = Faker.Name.Last())
                                 .With(c => c.Gender      = Faker.Extensions.ArrayExtensions.Random(gender))
                                 .With(c => c.HireDate    = DateTime.Now.AddDays(-daysGenerator.Next(1, 3650)))     // HireDate within last 10 years
                                 .With(c => c.BirthDate   = DateTime.Now.AddDays(-daysGenerator.Next(6750, 21170))) // Age between 18 to 58 Years
                                 .With(c => c.Address1    = Faker.Address.StreetAddress())
                                 .With(c => c.Address2    = Faker.Address.StreetName())
                                 .With(c => c.City        = Faker.Address.City())
                                 .With(c => c.State       = Faker.Address.UsStateAbbr())
                                 .With(c => c.Zipcode     = Faker.Address.ZipCode())
                                 .With(c => c.HomePhone   = Faker.Phone.Number())
                                 .With(c => c.MobilePhone = Faker.Phone.Number())
                                 .With(c => c.Email       = Faker.Internet.Email())

                                 .Build();



            foreach (var employee in employees)
            {
                try
                {
                    employee.HomePhone = employee.HomePhone.Replace("(", "").Replace(")", "").Replace("-", "");
                    if (employee.HomePhone.Length > 12)
                    {
                        employee.HomePhone = employee.HomePhone.Substring(0, 12);
                    }
                    else
                    {
                        employee.HomePhone = employee.HomePhone.Substring(0, employee.HomePhone.Length);
                    }
                    employee.MobilePhone = employee.MobilePhone.Replace("(", "").Replace(")", "").Replace("-", "");

                    if (employee.MobilePhone.Length > 12)
                    {
                        employee.MobilePhone = employee.MobilePhone.Substring(0, 12);
                    }
                    else
                    {
                        employee.MobilePhone = employee.MobilePhone.Substring(0, employee.MobilePhone.Length);
                    }
                    await _employeeService.AddEmployee(employee);
                }
                catch (Exception ex)
                {
                }
            }

            string[] departments = { "Transport",
                                     "Security",
                                     "Research and development",
                                     "Product development",
                                     "Learning and development",
                                     "IT services",
                                     "Infrastructures",
                                     "Engineering",
                                     "Business development",
                                     "Admin",
                                     "Accounts and Finance" };

            string[] titles = { "Vice-President",
                                "Senior Account Manager",
                                "Account Manager",
                                "Senior Project Manager",
                                "Project Manager",
                                "Senior Technical Lead",
                                "Technical Lead",
                                "Project Lead",
                                "Senior Team Lead",
                                "Team Lead",
                                "Module Lead",
                                "Senior Software Engineer",
                                "Software Engineer",
                                "Associate Software Engineer",
                                "Intern" };

            for (int i = 0; i < departments.Length; i++)
            {
                Department dept = new Department();
                dept.DeptNo = "D" + i;
                dept.Name   = departments[i];
                await _departmentService.AddDepartment(dept);

                var flag = false;
                while (!flag)
                {
                    try
                    {
                        var index = daysGenerator.Next(1, employees.Count);
                        var emp   = employees[index - 1];

                        DeptManager deptManager = new DeptManager();
                        deptManager.DeptNo   = dept.DeptNo;
                        deptManager.EmpNo    = emp.EmpNo;
                        deptManager.FromDate = DateTime.Now.AddDays(-daysGenerator.Next(1, 3650));
                        deptManager.ToDate   = deptManager.FromDate.Value.AddDays(daysGenerator.Next(1, 3650));

                        await _deptManagerService.AddDeptManager(deptManager);

                        flag = true;
                    }
                    catch (Exception)
                    {
                        flag = false;
                    }
                }
            }

            foreach (var employee in employees)
            {
                try
                {
                    var     index   = daysGenerator.Next(1, departments.Length);
                    var     dept    = departments[index - 1];
                    DeptEmp deptEmp = new DeptEmp();
                    deptEmp.DeptNo   = "D" + (index - 1).ToString();
                    deptEmp.EmpNo    = employee.EmpNo;
                    deptEmp.FromDate = DateTime.Now.AddDays(-daysGenerator.Next(1, 3650));
                    deptEmp.ToDate   = deptEmp.FromDate.Value.AddDays(daysGenerator.Next(1, 3650));
                    Expression <Func <DeptEmp, bool> > deptEmpPred = d => (d.EmpNo == employee.EmpNo && d.DeptNo == deptEmp.DeptNo);
                    var dept_emp = _deptEmpService.FindDeptEmp(deptEmpPred).Result.FirstOrDefault();
                    if (dept_emp == null)
                    {
                        await _deptEmpService.AddDeptEmp(deptEmp);
                    }

                    Salary salary = new Salary();
                    salary.EmpNo    = employee.EmpNo;
                    salary.Salary1  = daysGenerator.Next(25000, 200000);
                    salary.FromDate = DateTime.Now.AddDays(-daysGenerator.Next(1, 3650));
                    salary.ToDate   = salary.FromDate.Value.AddDays(daysGenerator.Next(1, 3650));
                    await _salaryService.AddSalary(salary);

                    index = daysGenerator.Next(1, titles.Length);
                    var   sTitle = titles[index - 1];
                    Title title  = new Title();
                    title.EmpNo    = employee.EmpNo;
                    title.Title1   = sTitle;
                    title.FromDate = DateTime.Now.AddDays(-daysGenerator.Next(1, 3650));
                    title.ToDate   = title.FromDate.Value.AddDays(daysGenerator.Next(1, 3650));
                    await _titleService.AddTitle(title);
                }
                catch (Exception ex)
                {
                }
            }


            return(View());
        }