private void SaveExecute()
        {
            try
            {
                var db = new DataAccess();
                Employee.Surname            = Surname;
                Employee.GivenName          = GivenName;
                Employee.LocationID         = Location.LocationID;
                Employee.Sex                = Sex.ToLower();
                Employee.PersonalNo         = PersonalNo;
                Employee.DateOfBirth        = GeneratingData.GenerateBirthdate(Employee.PersonalNo);
                EmployeeAge                 = GeneratingData.CalculateAge(Employee.DateOfBirth);
                Employee.Manager            = Manager;
                Employee.Telephone          = Telephone;
                Employee.RegistrationNumber = RegistrationNumber;
                if (Sectors.Any(s => s.Name == SectorName))
                {
                    Employee.SectorID = Sectors.First(s => s.Name == SectorName).SectorID;
                }
                else
                {
                    var newSector = new tblSector()
                    {
                        Name = SectorName
                    };
                    //adding new sector to database
                    db.AddNewSector(newSector);
                    Sectors           = LoadSectors();
                    Employee.SectorID = Sectors.FirstOrDefault(s => s.Name == SectorName).SectorID;
                }

                //updating employee
                db.UpdateEmployee(Employee.EmployeeID, Employee);

                workerUpdate.RunWorkerAsync();

                IsUpdatedEmployee = true;
                updateEmployeeView.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void SaveExecute()
        {
            try
            {
                var db = new DataAccess();
                Employee.Sex = Sex.ToLower();
                Employee.RegistrationNumber = RegistrationNumber;
                Employee.PersonalNo         = PersonalNo;
                Employee.LocationID         = Location.LocationID;
                Employee.DateOfBirth        = GeneratingData.GenerateBirthdate(Employee.PersonalNo);
                if (Sectors.Any(s => s.Name == SectorName))
                {
                    Employee.SectorID = Sectors.First(s => s.Name == SectorName).SectorID;
                }
                else
                {
                    var newSector = new tblSector()
                    {
                        Name = SectorName
                    };
                    //adding new sector to database
                    db.AddNewSector(newSector);
                    Sectors           = LoadSectors();
                    Employee.SectorID = Sectors.FirstOrDefault(s => s.Name == SectorName).SectorID;
                }


                //adding new employee to database
                db.AddNewEmployee(Employee);

                workerAddNew.RunWorkerAsync();

                IsAddedNewEmployee = true;

                addNewEmployeeView.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private string BuildUrl()
        {
            var url = $"{BaseUrl}trainingcourses?keyword={Keyword}";

            if (OrderBy != OrderBy.None)
            {
                url += $"&orderby={OrderBy}";
            }
            if (Sectors != null && Sectors.Any())
            {
                url += "&routeIds=" + string.Join("&routeIds=", Sectors.Select(HttpUtility.HtmlEncode));
            }
            if (Levels != null && Levels.Any())
            {
                url += "&levels=" + string.Join("&levels=", Levels);
            }

            if (_shortlistUserId.HasValue)
            {
                url += $"&shortlistUserId={_shortlistUserId}";
            }
            return(url);
        }
Exemplo n.º 4
0
 public bool Any()
 {
     return((Ministries?.Any() ?? false) || (Sectors?.Any() ?? false) || (Tags?.Any() ?? false) || (Services?.Any() ?? false) || (Newsletters?.Any() ?? false) || (Emergency?.Any() ?? false));
 }