예제 #1
0
        public bool SaveDepartment(Department department)
        {
            DepartmentGetway departmentGetway = new DepartmentGetway();

            try
            {
                if (IsValidDeptCode(department.Code))
                {
                    throw new Exception("Department code already exist.");
                }
                else
                {
                    if (IsValidDeptName(department.Name))
                    {
                        throw new Exception("Department name already exist.");
                    }
                    else
                    {
                        return(departmentGetway.SaveDepartment(department));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
 public Department GetDepartmentById(int id)
 {
     try
     {
         DepartmentGetway departmentGetway = new DepartmentGetway();
         return(departmentGetway.GetDepartmentById(id));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
 public List <Department> GetAllDepartment()
 {
     try
     {
         DepartmentGetway departmentGetway = new DepartmentGetway();
         return(departmentGetway.GetAllDepartment());
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #4
0
 private bool IsValidDeptName(string deptName)
 {
     try
     {
         DepartmentGetway departmentGetway = new DepartmentGetway();
         return(departmentGetway.IsValidDeptName(deptName));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #5
0
 public bool DeleteDepartment(int id)
 {
     try
     {
         DepartmentGetway departmentGetway = new DepartmentGetway();
         return(departmentGetway.DeleteDepartment(id));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #6
0
 public bool UpdateDepartment(Department dept)
 {
     try
     {
         DepartmentGetway departmentGetway = new DepartmentGetway();
         return(departmentGetway.UpdateDepartment(dept));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #7
0
        public string RegistraionNoGneraion(Student student)
        {
            // RegistraionNo = <Department>-<Year>-<SerialNo>
            List <string> registraionNos = studentGetway.RegistraionNoGneraion(student);


            // get the serial no
            string serialNo;

            // if there is no registraion No at that department and at that year
            if (!registraionNos.Any())
            {
                serialNo = "000";
            }
            else
            {
                // Extract the last 3 substring and convert them to int And Make the list again in integer form
                List <int> serialNoOfRegistraionNo = new List <int>();
                foreach (var regNo in registraionNos)
                {
                    string serialNoStringFormate = regNo.Substring(regNo.Length - 3);
                    int    serialNoIntFormate    = int.Parse(serialNoStringFormate);

                    serialNoOfRegistraionNo.Add(serialNoIntFormate);
                }

                // get the max serial no and convert it into 000 3 digit format
                serialNo = (serialNoOfRegistraionNo.Max() + 1).ToString("000");
            }


            // get the department code
            DepartmentGetway departmentGetway = new DepartmentGetway();
            string           code             = departmentGetway.RegistraionNoGeneraion(student.DeptId);


            // get the year form date
            string year = student.Date.Year.ToString();


            // Finally generate the registraion No
            return(code + "-" + year + "-" + serialNo);
        }
 public DepartmentManager()
 {
     _departmentGetway = new DepartmentGetway();
 }