示例#1
0
        public bool ValidateFaculty(FacultyEntity newFaculty)
        {
            bool          isValidFaculty = true;
            StringBuilder sbFMSError     = new StringBuilder();

            if (newFaculty.FacultyId.ToString().Equals(string.Empty))
            {
                isValidFaculty = false;
                sbFMSError.Append("Faculty Id cannot be blank " + Environment.NewLine);
            }

            if (!(Regex.IsMatch(newFaculty.FacultyName, "[A-Z][a-z]{3,}")))
            {
                isValidFaculty = false;
                sbFMSError.Append("Faculty Name must have only characters starting with uppercase " + Environment.NewLine);
            }
            if (newFaculty.DOJ >= DateTime.Now)
            {
                isValidFaculty = false;
                sbFMSError.Append("Faculty DOJ must not be a future Date " + Environment.NewLine);
            }
            if (!(Regex.IsMatch(newFaculty.Phone.ToString(), "[1-9][0-9]{9}")))
            {
                isValidFaculty = false;
                sbFMSError.Append("Faculty phone should have 10 digits and first digit cannot be 0 " + Environment.NewLine);
            }

            if (!isValidFaculty)
            {
                throw new FacultyException(sbFMSError.ToString());
            }

            return(isValidFaculty);
        }
        private static void SearchFaculty()
        {
            FacultyEntity empSearch = null;

            try
            {
                Console.WriteLine("Enter faculty phone no to be searched:");
                long?phone = Int64.Parse(Console.ReadLine());

                empSearch = objValidation.SearchFacultyBAL(phone);
                if (empSearch != null)
                {
                    Console.WriteLine("Searched Employee Details:");
                    Console.WriteLine("Employee id: {0}", empSearch.FacultyId);
                    Console.WriteLine("Employee Name: {0}", empSearch.FacultyName);
                    Console.WriteLine("Employee email: {0}", empSearch.Email);
                    Console.WriteLine("Employee Contact: {0}", empSearch.Phone);
                    Console.WriteLine("Employee DOJ : {0}", empSearch.DOJ.ToShortDateString());
                }
            }
            catch (FacultyException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 public static FacultyDomain Create(FacultyEntity facultyEntity)
 {
     return(new FacultyDomain(
                facultyEntity.FacultyId,
                facultyEntity.Title,
                facultyEntity.FacultyCode
                ));
 }
        private void faculty_combobx_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox facultyComboBx = sender as ComboBox;

            if (facultyComboBx.SelectedItem != null)
            {
                FacultyEntity selectedFac = facultyComboBx.SelectedItem as FacultyEntity;
                faculty_combobx_val = selectedFac.FacultyName;
                CheckValidations();
            }
        }
示例#5
0
        /// <summary>
        /// To add new faculty into the List/Collection
        /// </summary>
        /// <param name="newFaculty"></param>
        /// <returns></returns>
        public bool AddFacultyDAL(FacultyEntity newFaculty)
        {
            bool isFacultyAdded = false;

            try
            {
                facultyList.Add(newFaculty);
                isFacultyAdded = true;
            }
            catch (FacultyException)
            {
                throw;
            }

            return(isFacultyAdded);
        }
示例#6
0
        public FacultyEntity SearchFacultyBAL(long?phone)
        {
            FacultyEntity searchedFaculty = null;

            try
            {
                operationsObj   = new Faculty_DAL();
                searchedFaculty = operationsObj.SearchFacultyDAL(phone);
                if (searchedFaculty == null)
                {
                    throw new FacultyException("Faculty not found");
                }
            }
            catch (FacultyException ex) { throw ex; }
            return(searchedFaculty);
        }
示例#7
0
        public bool AddFacultyBAL(FacultyEntity newFaculty)
        {
            bool isFacultyAdded = false;

            try
            {
                operationsObj = new Faculty_DAL();
                if (ValidateFaculty(newFaculty))
                {
                    isFacultyAdded = operationsObj.AddFacultyDAL(newFaculty);
                }
                else
                {
                    throw new FacultyException("Validation Failed!!!Faculty Record could not be added");
                }
            }
            catch (FacultyException)
            {
                throw;
            }
            return(isFacultyAdded);
        }
        public static void AddFaculty()
        {
            try
            {
                objValidation = new Faculty_BAL();
                FacultyEntity empNew = new FacultyEntity();

                Console.WriteLine("Enter faculty Id :");



                empNew.FacultyId = Int32.Parse(Console.ReadLine());
                Console.WriteLine("Enter faculty Name :");
                empNew.FacultyName = Console.ReadLine();
                Console.WriteLine("Enter faculty DOJ :");
                empNew.DOJ = DateTime.Parse(Console.ReadLine());
                Console.WriteLine("Enter faculty email :");
                empNew.Email = Console.ReadLine();
                Console.WriteLine("Enter faculty phone :");
                empNew.Phone = Int64.Parse(Console.ReadLine());

                if (objValidation.AddFacultyBAL(empNew))
                {
                    Console.WriteLine("faculty Record added successfully");
                }
            }
            catch (FacultyException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }