public HttpResponseMessage RequestRegistrationBranchStudent([FromBody] BranchStudentDto branchStudentDto) { //private StudentController db = new StudentController(); try { BranchStudent branchStud = Converters.Convert(branchStudentDto); if (!ValidateModel.IsValid(new List <object>() { branchStud })) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ValidateModel.ModelsResults)); } Students s = StudentManager.GetStudents(Student.Includes.Address | Student.Includes.Bank | Student.Includes.Children, null, null); int f = 0; //foreach (var item in s.students) //{ // if (item.IdentityNumber == branchStud.Student.IdentityNumber) // { // branchStud.Student.Id = item.Id; // f = 1; // } //} //if(f==0) // return Request.CreateResponse(HttpStatusCode.BadRequest); BranchStudentManager.RequestRregistration(branchStud); return(Request.CreateResponse(HttpStatusCode.OK, branchStud.Id)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Failed to insert the student to branch, {ex.Message}")); } }
public static int RequestRregistration(BranchStudent branchStudent) { try { int insert = BranchStudentDataManager.RequestRegistrationBranchStudent(branchStudent); return(insert); } catch (Exception) { _logger.Debug($"Failed to insert the requested branch by student."); throw; } }
public HttpResponseMessage ApprovalRegistration([FromBody] BranchStudentDto branchStudentDto) { try { //TODO not in that sprint-create login BranchStudent branchStudent = Converters.Convert(branchStudentDto); int update = StudentManager.ApprovalRegistration(branchStudent); return(Request.CreateResponse(HttpStatusCode.OK, update)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Failed to approve registration for the student in this Branch.")); } }
public static BranchesStudents Convert(List <BranchStudentDto> studentBranchsDto) { if (studentBranchsDto != null) { BranchesStudents studentsBranchs = new BranchesStudents(); foreach (BranchStudentDto studentBranch in studentBranchsDto) { BranchStudent item = Convert(studentBranch); studentsBranchs.Add(item); } return(studentsBranchs); } return(null); }
public int RequestRegistrationBranchStudent(BranchStudent branchStudent) { IList <DbParameter> parameters = new List <DbParameter>() { new MySqlParameter("@student_id", branchStudent.Student.Id), //branchStudent.Student.Id new MySqlParameter("@branch_id", branchStudent.Branch.Id), //branchStudent.Branch.Id new MySqlParameter("@branch_study_path_id", 1), //branchStudent.StudyPath.Id new MySqlParameter("@entry_gregorian_date", branchStudent.EntryGregorianDate), new MySqlParameter("@entry_hebrew_date", branchStudent.EntryHebrewDate), new MySqlParameter("@release_hebrew_date", branchStudent.ReleaseHebrewDate), new MySqlParameter("@release_gregorian_date", branchStudent.ReleaseGregorianDate), new MySqlParameter("@status", StatusInBranch.Pending.ToString()), new MySqlParameter("@is_active", false) }; return(_dbContext.Insert(Tables.BranchStudents.InsertTable, true, parameters)); }
public static int ApprovalRegistration(BranchStudent branchStudent) { try { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { int update = BranchStudentManager.ApprovalRegistrationStudent(branchStudent.Id); StudentDataManager.SetStudentActive(branchStudent.Student.Id); if (update == 1) { BranchManager.IncreaseNumberOfStudents(branchStudent.Branch.Id); } scope.Complete(); return(update); } } catch (Exception ex) { _logger.Debug($"Failed to set the student {branchStudent.Student.Id} to active in branch {branchStudent.Branch.Id}.", ex); throw; } }
public static BranchStudentDto Convert(BranchStudent studentBranch) { if (studentBranch == null) { return(null); } return(new BranchStudentDto() { Id = studentBranch.Id, Student = new Student() { Id = studentBranch.Student.Id }, Branch = studentBranch.Branch, EntryHebrewDate = studentBranch.EntryHebrewDate, EntryGregorianDate = studentBranch.EntryGregorianDate, ReleaseGregorianDate = studentBranch.ReleaseGregorianDate, ReleaseHebrewDate = studentBranch.ReleaseHebrewDate, IsActive = studentBranch.IsActive, Status = studentBranch.Status, StudyPath = studentBranch.StudyPath, }); }