/// <summary> /// Function that updates a teacher record that the user wants to change if they choose option 2 from the menu /// </summary> /// <param name="teacherTable">list that contains teachers that are stored in the table</param> /// <param name="businessLayer">business layer object used to call a function im order to update a teacher record</param> public static void UpdateTeacher(IEnumerable <Teacher> teacherTable, IBusinessLayer businessLayer) { DisplayTeachers(); Console.WriteLine("Search Teacher by ID or Name?"); Console.WriteLine("[1] ID"); Console.WriteLine("[2] Name"); int choice = Convert.ToInt32(Console.ReadLine()); if (choice == 1) { Console.WriteLine("Enter Teacher ID: "); int tchrID = Convert.ToInt32(Console.ReadLine()); Teacher tchr = businessLayer.GetTeacherByID(tchrID); Teacher newTeacher = tchr; Console.WriteLine("Enter the new teacher name: "); newTeacher.TeacherName = Console.ReadLine(); businessLayer.UpdateTeacher(newTeacher); } else if (choice == 2) { Console.WriteLine("Enter Teacher Name: "); string tchrName = Console.ReadLine(); Teacher tchr = businessLayer.GetTeacherByName(tchrName); Console.WriteLine("Enter the new Teacher name: "); tchr.TeacherName = Console.ReadLine(); businessLayer.UpdateTeacher(tchr); } else { Console.WriteLine("Option not there"); } }
/// <summary> /// Function used to add in updating a specific course from course table in dtabase /// </summary> /// <param name="courseTable">enumerable lisr that contains all the courses from database </param> /// <param name="businessLayer">object used to aid to update a course by calling a specific function</param> public static void UpdateCourse(IEnumerable <Course> courseTable, IBusinessLayer businessLayer) { DisplayCourses(courseTable, businessLayer); Console.WriteLine("Search Course by ID or Name?"); Console.WriteLine("1. ID"); Console.WriteLine("2. Name"); int choice = Convert.ToInt32(Console.ReadLine()); if (choice == 1) { Console.WriteLine("Enter Course ID: "); int courseID = Convert.ToInt16(Console.ReadLine()); Course course = businessLayer.GetCourseByID(courseID); Console.WriteLine("Enter the new Course name: "); course.CourseName = Console.ReadLine(); Console.WriteLine("Enter new Teacher ID: "); course.TeacherId = Convert.ToInt32(Console.ReadLine()); businessLayer.UpdateCourse(course); } else if (choice == 2) { Console.WriteLine("Enter Course Name: "); string courseName = Console.ReadLine(); Course course = businessLayer.GetCourseByName(courseName); Console.WriteLine("Enter the new Course name: "); Course modCourse = businessLayer.GetCourseByID(course.CourseId); modCourse.CourseName = Console.ReadLine(); businessLayer.UpdateCourse(modCourse); } else { Console.WriteLine("Wrong Choice"); } }
static void addTeacher(IBusinessLayer bl, string teacherName, int standardID) { Teacher newTeach = new Teacher() { TeacherName = teacherName }; Standard std = bl.GetStandardByID(standardID); if (std != null) { // TODO Just set the standardID // TODO ask about this case. newTeach.Standard = std; } else { newTeach.Standard = new Standard() { StandardName = "New Standard 1" }; } bl.AddTeacher(newTeach); }
public HomeController( IBusinessLayer businessLayer, IAuthentication auth) { _businessLogic = businessLayer; _auth = auth; }
public async void GetStationAsyncShouldReturnResourceDoesNotBelongToCurrentUserWhenNecessesary(string returnedUser, string currentUser, bool shouldMatch) { // Arrange // Configure GetStationAsync to return the provided returnedUser this.dataLayer.GetStationAsync(Arg.Any <int>()).Returns(new Station() { UserId = returnedUser }); // Create the provided currentUser this.user = new UserStub(currentUser); // Re-initialize the business layer so that it takes the new user object this.businessLayer = new BusinessLayer(this.dataLayer, this.user, this.mapper); // Act: Run GetStationAsync var response = await this.businessLayer.GetStationAsync(1); /* Assert that the we're returning either ResourceDoesNotBelongToCurrentUser or a Station * based on the shouldMatch input. */ if (!shouldMatch) { Assert.True(response.IsLeft); Assert.Equal(BusinessOperationFailureReason.ResourceDoesNotBelongToCurrentUser, response.LeftValue); } else { Assert.True(response.IsRight); } }
public static void DisplayAll <T>(IBusinessLayer DataAccess) { if (DataAccess != null) { if (typeof(T).Equals(typeof(Course))) { foreach (var course in DataAccess.GetAllCourses()) { Console.WriteLine(course.CourseId + " " + course.CourseName); } return; } if (typeof(T).Equals(typeof(Teacher))) { foreach (var teacher in DataAccess.GetAllTeachers()) { Console.WriteLine(teacher.TeacherId + " " + teacher.TeacherName); Console.WriteLine("Teacher courses:"); foreach (var course in teacher.Courses) { Console.WriteLine(course.CourseName + " | ID: " + course.CourseId); } } return; } } }
public MyApplication(ILogger <MyApplication> logger, IBusinessLayer business, IHttpClientFactory httpFactory) { _logger = logger; _business = business; _httpFactory = httpFactory; }
public static void RemoveCourse(IBusinessLayer DataAccess) { DisplayAll <Course>(DataAccess); Course selected; Console.Write("\nEnter course id to remove: "); try { int courseID = Convert.ToInt32(Console.ReadLine()); selected = DataAccess.GetCourseByID(courseID); if (selected != null) { foreach (var student in selected.Students) { student.Courses.Remove(selected); } //selected.Teacher.Courses.Remove(selected); DataAccess.RemoveCourse(selected); Console.WriteLine(selected.CourseName + " has been removed!"); } } catch (Exception) { Console.WriteLine("invalid input"); } }
public static Teacher UpdateTeacher(IBusinessLayer DataAccess) { IEnumerable <Teacher> teacherList = DataAccess.GetAllTeachers(); Console.WriteLine("\nTeacher List..."); foreach (Teacher teacher in teacherList) { Console.WriteLine(teacher.TeacherId + " " + teacher.TeacherName); } Console.Write("\nEnter a teacher id to update: "); Teacher selected; //try //{ int teacherID = Convert.ToInt32(Console.ReadLine()); selected = DataAccess.GetTeacherByID(teacherID); Console.WriteLine("\nEnter a new teacher name"); string name = Console.ReadLine(); selected.TeacherName = name; //Update teacher with the selected ID DataAccess.UpdateTeacher(teacherID); return(selected); //} return(null); }
public static Teacher UpdateTeacherByName(IBusinessLayer DataAccess) { IEnumerable <Teacher> teacherList = DataAccess.GetAllTeachers(); Console.WriteLine("\nTeacher List..."); foreach (Teacher teacher in teacherList) { Console.WriteLine(teacher.TeacherId + " " + teacher.TeacherName); } Console.Write("\nEnter a teacher name to update: "); Teacher selected = null; try { string teacherName = Console.ReadLine(); Teacher result = DataAccess.GetTeacherByName(teacherName); if (result != null) { selected = DataAccess.GetTeacherByID(result.TeacherId); } if (selected != null) { Console.WriteLine("\nEnter a new teacher name"); string name = Console.ReadLine(); selected.TeacherName = name; DataAccess.UpdateTeacher(selected.TeacherId); return(selected); } } catch (Exception) { } return(null); }
} //close ViewStudent(...) static string ValidateStudentName(IBusinessLayer businessLayerInst) { Student studentName = null; //get valid standard name string desiredStudentName = "initialize"; IList <Student> studentsByName = new List <Student>(); while (studentName == null) { //Display all of the standard data Console.WriteLine("Available Standard Names to choose from:"); //Display all of the student names studentsByName = businessLayerInst.getAllStudents(); Console.WriteLine("{0, -20}", "Student Name:"); foreach (var listItem in studentsByName) { Console.WriteLine("{0, -20}", listItem.StudentName); } Console.Write("\nPlease Enter the Desired StandardName of the desired Standard:"); //attempt to convert the user input into an integer desiredStudentName = Console.ReadLine(); //attempt to retrieve the standard by the standardname input from user. studentName = businessLayerInst.GetStudentByName(desiredStudentName); } //end while return(desiredStudentName); } //close ValidateStudentName(...)
public static bool RemoveTeacher(IBusinessLayer DataAccess) { IEnumerable <Teacher> teacherList = DataAccess.GetAllTeachers(); Console.WriteLine("\nCourse List..."); foreach (Teacher teacher in teacherList) { Console.WriteLine(teacher.TeacherId + " " + teacher.TeacherName); } Teacher selected; Console.Write("\nEnter teacher id to remove: "); try { int teacherID = Convert.ToInt32(Console.ReadLine()); selected = DataAccess.GetTeacherByID(teacherID); if (selected != null) { DataAccess.RemoveTeacher(selected); Console.WriteLine(selected.TeacherName + " has been removed!"); } return(true); } catch (Exception) { Console.WriteLine("invalid input"); } return(false); }
/// <summary> /// Function that allows user to delete a record from the teacher table /// </summary> /// <param name="teacherTable">list that contains all the teachers from the database table</param> /// <param name="businessLayer">business layer object used to call a function to delete teacher</param> public static void DeleteTeacher(IEnumerable <Teacher> teacherTable, IBusinessLayer businessLayer) { DisplayTeachers(); Console.WriteLine("Enter Teacher ID you want to Delete: "); int tchrID = Convert.ToInt32(Console.ReadLine()); Teacher tchr = businessLayer.GetTeacherByID(tchrID); businessLayer.RemoveTeacher(tchr); }
public AccountController( SignInManager <ApplicationUser> signInManager, IConfiguration configuration, UserManager <ApplicationUser> userManager, IBusinessLayer businessLayer) { this.signInManager = signInManager; this.configuration = configuration; this.userManager = userManager; this._businessLayer = businessLayer; }
public void bl_should_return_Picture_by_ID() { IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); IPictureModel obj = bl.GetPicture(1234); AssertNotNull("bl.GetPicture", obj); }
static void print_all_teachers(IBusinessLayer bl) { IList <Teacher> st = bl.GetAllTeachers(); foreach (var elm in st) { string message = "Name: {0}"; Console.WriteLine(string.Format(message, elm.TeacherName)); } }
public async void SouldGetAllStationsForCurrentUser(UserStub user) { // Arrange: Init the business layer with the provided user this.businessLayer = new BusinessLayer(this.dataLayer, user, this.mapper); // Act: Perform GetAllStations await this.businessLayer.GetAllStations(); // Assert that the proper user id was passed to GetAllStationsForUserAsync await this.dataLayer.Received(1).GetAllStationsForUserAsync(user.UniqueId); }
public void bl_should_return_Photographer_by_ID() { IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); IPhotographerModel obj = bl.GetPhotographer(1234); AssertNotNull("bl.GetPhotographer", obj); }
public void bl_should_return_Camera_by_ID() { IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); ICameraModel obj = bl.GetCamera(1234); AssertNotNull("bl.GetCamera", obj); }
public void bl_should_extract_fake_EXIF_Info_from_missing_picture() { EnsureTestImages(); IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); Assert.That(() => bl.ExtractEXIF("Missing_Imgage.jpg"), Throws.Exception); }
static void print_all_students(IBusinessLayer bl) { IList <Student> st = bl.GetAllStudents(); foreach (var elm in st) { string message = "Name: {0}"; Console.WriteLine(string.Format(message, elm.StudentName)); } }
public void bl_should_return_Pictures() { IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); IEnumerable <IPictureModel> lst = bl.GetPictures(null, null, null, null); AssertNotNull("bl.GetPictures", lst); AssertTrue("bl.GetPictures returned nothing", lst.Count() > 0); }
public void bl_should_return_Photographers() { IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); IEnumerable <IPhotographerModel> lst = bl.GetPhotographers(); AssertNotNull("bl.GetPhotographers", lst); AssertTrue("bl.GetPhotographers returned nothing", lst.Count() > 0); }
public void bl_should_return_Cameras() { IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); IEnumerable <ICameraModel> lst = bl.GetCameras(); AssertNotNull("bl.GetCameras", lst); AssertTrue("bl.GetCameras returned nothing", lst.Count() > 0); }
public BusinessLayerTests() { this.user = new UserStub("Dummy Test User"); var mappingConfig = new MapperConfiguration(mc => { mc.AddProfile(new MappingProfile()); }); this.mapper = mappingConfig.CreateMapper(); this.dataLayer = Substitute.For <IDataLayer>(); this.businessLayer = new BusinessLayer(this.dataLayer, this.user, this.mapper); }
public void bl_should_search_Pictures() { IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); IEnumerable <IPictureModel> lst = bl.GetPictures("blume", null, null, null); AssertNotNull("bl.GetPictures", lst); AssertEquals("bl.GetPictures().count != 1", 1, lst.Count()); }
/// <summary> /// Function used to delete a course record from a table /// </summary> /// <param name="courseTable">ienumerable list that contains all the courses that are stored in the database</param> /// <param name="businessLayer">object used to help in deleteing a course by calling functions that may prove helpful</param> public static void DeleteCourse(IEnumerable <Course> courseTable, IBusinessLayer businessLayer) { DisplayCourses(courseTable, businessLayer); Console.WriteLine("Enter Course ID you want to delete: "); int courseID = Convert.ToInt32(Console.ReadLine()); Course course = businessLayer.GetCourseByID(courseID); Console.WriteLine(course.CourseName); businessLayer.RemoveCourse(course); }
/// <summary> /// function that displays all the courses /// </summary> /// <param name="courseTable">list containing all the courses stored in database table</param> /// <param name="businessLayer">object used to aid in displaying courses</param> public static void DisplayCourses(IEnumerable <Course> courseTable, IBusinessLayer businessLayer) { Console.WriteLine("DisplayCourses"); Console.WriteLine("\tCourse ID\tNames"); courseTable = businessLayer.GetAllCourses(); foreach (Course c in courseTable) { Console.WriteLine("\t\t" + c.CourseId + "\t\t" + c.CourseName); } Console.WriteLine(); }
public void bl_should_extract_IPTC_Info_from_existing_picture() { EnsureTestImages(); IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); IIPTCModel iptc = bl.ExtractIPTC("Img1.jpg"); AssertNotNull("ExtractIPTC", iptc); }
public void BL_should_sync() { EnsureTestImages(); IBusinessLayer bl = ueb.GetBusinessLayer(); AssertNotNull("GetBusinessLayer", bl); bl.Sync(); AssertEquals(Constants.PictureCount, bl.GetPictures().Count()); }
public PersonController(IBusinessLayer businessLayer) { this.businessLayer = businessLayer; }