/// <summary> /// Check fields of object employee /// </summary> /// <param name="employee">Object Employee</param> private void CheckFields(Employee employee) { if (!StringLib.CheckNull(employee.Name)) { throw new Exception("Name required"); } if (!StringLib.CheckNull(employee.Email)) { throw new Exception("Email required"); } if (!StringLib.CheckNull(employee.Department)) { throw new Exception("Department required"); } if (!StringLib.CheckLenght(employee.Name, 100)) { throw new Exception("Maximum Name length: 100 characters"); } if (!StringLib.CheckLenght(employee.Email, 100)) { throw new Exception("Maximum Email length: 100 characters"); } if (!StringLib.CheckLenght(employee.Department, 100)) { throw new Exception("Maximum Department length: 100 characters"); } if (!EmailLib.IsValidEmail(employee.Email)) { throw new Exception("Invalid Email"); } if (_context.Employee.FirstOrDefault(e => e.Email == employee.Email) != null) { throw new Exception("Email already exists"); } }