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; } }
public Department GetDepartmentById(int id) { try { DepartmentGetway departmentGetway = new DepartmentGetway(); return(departmentGetway.GetDepartmentById(id)); } catch (Exception) { throw; } }
public List <Department> GetAllDepartment() { try { DepartmentGetway departmentGetway = new DepartmentGetway(); return(departmentGetway.GetAllDepartment()); } catch (Exception) { throw; } }
private bool IsValidDeptName(string deptName) { try { DepartmentGetway departmentGetway = new DepartmentGetway(); return(departmentGetway.IsValidDeptName(deptName)); } catch (Exception) { throw; } }
public bool DeleteDepartment(int id) { try { DepartmentGetway departmentGetway = new DepartmentGetway(); return(departmentGetway.DeleteDepartment(id)); } catch (Exception) { throw; } }
public bool UpdateDepartment(Department dept) { try { DepartmentGetway departmentGetway = new DepartmentGetway(); return(departmentGetway.UpdateDepartment(dept)); } catch (Exception) { throw; } }
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(); }