public int Update(Data.Models.Student student) { Data.Models.Student existingStudent = _studentRepository.Table.FirstOrDefault(w => w.Id == student.Id); if (existingStudent != null) { existingStudent.FirstName = student.FirstName; existingStudent.MiddleName = student.MiddleName; existingStudent.LastName = student.LastName; existingStudent.Gender = student.Gender; existingStudent.Address = student.Address; existingStudent.Mobile = student.Mobile; existingStudent.DOB = student.DOB; existingStudent.Email = student.Email; existingStudent.Remarks = student.Remarks; existingStudent.School = student.School; existingStudent.College = student.College; existingStudent.SCAddress = student.SCAddress; existingStudent.ContactName = student.ContactName; existingStudent.ContactNumber = student.ContactNumber; existingStudent.ContactRelation = student.ContactRelation; existingStudent.OriginalFileName = student.OriginalFileName; existingStudent.SystemFileName = student.SystemFileName; existingStudent.RegistrationNo = student.RegistrationNo; existingStudent.IsRegistered = student.IsRegistered; _studentRepository.Update(existingStudent); return(existingStudent.Id); } else { return(0); } }
public void ExecuteProcedure_AddStudent(Data.Models.Student student) { /*var sql = "INSERT INTO [dbo].[Student] ([Id],[FirstName],[LastName],[Email],[Address],[City],[Zip],[Phone])" + * "VALUES(@id, @firstName, @lastName, @email, @address, @city, @zip, @phone)"; * this.db.Execute(sql, student);*/ this.db.Execute("spStudent_AddStudent", student, commandType: CommandType.StoredProcedure); }
public List <Data.Models.Student> ExecuteProcedure_GetAllStudent() { List <Data.Models.Student> studentList = new List <Data.Models.Student>(); using (var sqlConnection = new SqlConnection(connString2)) { using (var command = sqlConnection.CreateCommand()) { command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "spStudent_GetAll"; sqlConnection.Open(); using (var dataReader = command.ExecuteReader()) { Data.Models.Student student; while (dataReader.Read()) { student = new Data.Models.Student(); student.ID = (Guid)dataReader["Id"];//new Guid((string)dataReader["Id"]); student.FirstName = Convert.ToString(dataReader["FirstName"]); student.LastName = Convert.ToString(dataReader["LastName"]); student.Email = Convert.ToString(dataReader["Email"]); student.Address = Convert.ToString(dataReader["Address"]); student.City = Convert.ToString(dataReader["City"]); student.ZIP = Convert.ToString(dataReader["Zip"]); student.Phone = Convert.ToString(dataReader["Phone"]); //add student to the list studentList.Add(student); } } } } return(studentList); }
public JsonNetResult GetStudentByEditId(int Id) { Data.Models.Student objStudent = this._studentService.GetForEditId(Id); StudentViewModel Student = new StudentViewModel { Id = objStudent.Id, InquiryId = objStudent.InquiryId, FirstName = objStudent.FirstName, MiddleName = objStudent.MiddleName, LastName = objStudent.LastName, Gender = Convert.ToChar(objStudent.Gender), Mobile = objStudent.Mobile, Address = objStudent.Address, Email = objStudent.Email, DOB = objStudent.DOB, Remarks = objStudent.Remarks, RegistrationNo = objStudent.RegistrationNo }; Data.Models.Inquiry objInquiry = this._inquiryService.GetForId(Id); InquiryViewModel Inquiry = new InquiryViewModel { Id = objInquiry.Id, Remark = objInquiry.Remark, DivisionId = objInquiry.DivisionId, SubjectId = objInquiry.SubjectId }; return(JsonNet(new { Student = Student, Inquiry = Inquiry }, JsonRequestBehavior.AllowGet)); }
public Data.Models.Student ExecuteProcedure_GetById(Guid id) { Data.Models.Student student = null; using (var sqlConnection = new SqlConnection(connString2)) { using (var command = sqlConnection.CreateCommand()) { command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "spStudent_GetById"; //command.Parameters["@Id"].Value = id; command.Parameters.AddWithValue("@id", id); sqlConnection.Open(); using (var dataReader = command.ExecuteReader()) { while (dataReader.Read()) { student = new Data.Models.Student(); student.ID = (Guid)dataReader["Id"]; student.FirstName = Convert.ToString(dataReader["FirstName"]); student.LastName = Convert.ToString(dataReader["LastName"]); student.Email = Convert.ToString(dataReader["Email"]); student.Address = Convert.ToString(dataReader["Address"]); student.City = Convert.ToString(dataReader["City"]); student.ZIP = Convert.ToString(dataReader["Zip"]); student.Phone = Convert.ToString(dataReader["Phone"]); } } } } return(student); }
private static object CreateStudent(Data.Models.Student student) { using (var dataContext = new SnapDataContext()) { var amountOfAnswers = dataContext.Answers .Count(a_item => a_item.Student.ID == student.ID && a_item.SubmitDateTime <= HomeController.CurrentDateTime); var lastAnswer = dataContext.Answers .Where(a_item => a_item.Student.ID == student.ID) .Where(a_item => a_item.SubmitDateTime <= HomeController.CurrentDateTime) .OrderByDescending(a_item => a_item.SubmitDateTime) .FirstOrDefault(); DateTime?lastAnswerDateTime = null; if (lastAnswer != null) { lastAnswerDateTime = lastAnswer.SubmitDateTime; } return(new { student.ID, student.ProfilePictureLocation, AmountOfAnswers = amountOfAnswers, LastAnswerDateTime = lastAnswerDateTime?.ToString("dd-MM-yyyy HH:mm") }); } }
public async Task <IActionResult> Get([FromQuery] Paging paging = default) { Data.Models.Student student = _userService.CurrentUser as Data.Models.Student; IEnumerable <Group> group = await _groupService.GetGroupsAsync(student); return(Ok(_mapper.Map <IEnumerable <Group>, IEnumerable <GroupSubjectDto> >(group))); }
protected override void OnInitialized() { student = new Data.Models.Student(); LoadStudentData(); base.OnInitialized(); }
public IActionResult Get() { int id = _userService.UserId; Data.Models.Student user = _userRepository.GetById(id) as Data.Models.Student; return(Ok(_mapper.Map <StudentProfileDto>(user))); }
public JsonNetResult SaveInquiry(Data.Models.Student student, Data.Models.Inquiry inquiry, Data.Models.StudentProgram StudentProgram, bool IsRegisterCheck) { JsonResponse response = new JsonResponse(); try { if (student.Id == 0) { inquiry.InquiryDate = DateTime.UtcNow; student.IsActive = true; student.RelativePath = null; student.Remarks = null; student.Inquiry = inquiry; //this._inquiryService.Insert(inquiry); int id = this._studentService.Insert(student); response.Data = new { StudentId = id }; response.Status = ResponseStatus.Success; } else { if (IsRegisterCheck == true) { StudentProgram.RegistrationDate = DateTime.UtcNow; student.IsRegistered = true; StudentProgram.NextDueDate = DateTime.UtcNow; StudentProgram.IsActive = true; this._studentService.Update(student); int errorCode = 0; int studentProgramId = this._studentprogramService.Insert(StudentProgram, out errorCode); if (errorCode == 101) { response.Status = ResponseStatus.Warning; response.Message = "Student already registered with same division and subject."; } else { response.Data = new { StudentId = student.Id, StudentProgramId = studentProgramId }; response.Status = ResponseStatus.Success; response.Message = "Registration successfully."; } } else { this._studentService.UpdateInquiry(student, inquiry); response.Data = new { StudentId = student.Id }; response.Status = ResponseStatus.Success; response.Message = "Information successfully updated."; } } } catch (Exception ex) { response.Status = ResponseStatus.Error; response.Message = ex.Message + ex.InnerException ?? ex.InnerException.Message + ex.StackTrace; LogException(ex); } return(JsonNet(response, JsonRequestBehavior.AllowGet)); }
public void SendMessage(Data.Models.Student message, string type) { var obj = new Message { Student = message, Type = type }; var payload = JsonConvert.SerializeObject(obj); _model.BasicPublish("", QueueName, true, null, Encoding.ASCII.GetBytes(payload)); }
public void TeachClassesStudentsTest() { var t = Repository.GetTeacher("*****@*****.**"); var @class = new AssessmentApp.Data.Models.Class { TeacherId = t.Id, ClassName = "Class - " + Guid.NewGuid().ToString(), Active = true }; Repository.CreateClass(@class); if (!Repository.CheckIfClassAlreadyExists(t.Id, @class.ClassName)) { Assert.Fail("CheckIfClassAlreadyExists should return true"); } Repository.UpdateClass(@class); var c = Repository.GetClass(@class.Id.Value); if (c == null) { Assert.Fail("Where is the class"); } var s = new Data.Models.Student { ClassId = @class.Id, StudentDateOfBirth = DateTime.Parse("1/1/2010"), StudentName = "Todd Test", Active = true }; s = Repository.CreateStudent(s); s.StudentName = "Todd Test 2"; Repository.UpdateStudent(s); var students = Repository.GetStudents(@class.TeacherId); if (!students.Any()) { Assert.Fail("Where are the students"); } if (!Repository.IsChild(t.Id, s)) { Assert.Fail("Is child check failed"); } Assert.Pass(); }
public IActionResult Edit(StudentProfileDto profile) { int id = _userService.UserId; Data.Models.Student user = _userRepository.GetById(id) as Data.Models.Student; _mapper.Map(profile, user); _db.SaveChanges(); return(Ok()); }
public void ExecuteProcedure_UpdateStudent(Data.Models.Student student) { /*var sql = "UPDATE [dbo].[Student] " + * "set [FirstName] = @firstName, " + * " [LastName] = @lastName, " + * " [Email] = @email, " + * " [Address] = @address, " + * " [City] = @city, " + * " [Zip] = @zip," + * " [Phone] = @phone" + * "where [Id] = @id"; * this.db.Execute(sql,student);*/ this.db.Execute("spStudent_UpdateStudent", student, commandType: CommandType.StoredProcedure); }
public Data.Models.Student ExecuteProcedure_DeleteById(Guid id) { Data.Models.Student student = null; using (var sqlConnection = new SqlConnection(connString2)) { using (var command = sqlConnection.CreateCommand()) { command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "spStudent_DeleteById"; command.Parameters.AddWithValue("@id", id); sqlConnection.Open(); command.ExecuteNonQuery(); } } return(student); }
public JsonNetResult SaveStudent(Data.Models.Student student) { JsonResponse response = null; try { response = new JsonResponse(); student.IsRegistered = true; this._studentService.Update(student); response.Status = ResponseStatus.Success; response.Message = "Data saved successfully."; } catch (Exception ex) { response.Status = ResponseStatus.Error; response.Message = ex.Message + ex.InnerException ?? ex.InnerException.Message; LogException(ex); } return(JsonNet(response, JsonRequestBehavior.AllowGet)); }
public void ExecuteProcedure_AddStudent(Data.Models.Student student) { using (var sqlConnection = new SqlConnection(connString2)) { using (var command = sqlConnection.CreateCommand()) { command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "spStudent_AddStudent"; command.Parameters.AddWithValue("@id", student.ID); command.Parameters.AddWithValue("@firstname", student.FirstName); command.Parameters.AddWithValue("@lastname", student.LastName); command.Parameters.AddWithValue("@email", student.Email); command.Parameters.AddWithValue("@address", student.Address); command.Parameters.AddWithValue("@city", student.City); command.Parameters.AddWithValue("@zip", student.ZIP); command.Parameters.AddWithValue("@phone", student.Phone); sqlConnection.Open(); command.ExecuteNonQuery(); } } }
public async Task <IActionResult> AddStudent(int groupId, string email = null, int?id = null) { if (string.IsNullOrWhiteSpace(email) && id == null) { return(BadRequest("No groupId or email specified")); } if (!new EmailAddressAttribute().IsValid(email)) { ModelState.AddModelError("email", "Неверный email"); return(BadRequest(ModelState)); } Group group = await _groupService.GetByIdAsync(groupId); if (group == null) { return(NotFound("No group")); } if (group.TeacherId != _userService.UserId) { return(Forbid()); } Data.Models.Student student = _userRepository.FindUserByEmail(email) as Data.Models.Student; if (student == null) { return(NotFound()); } if (_groupService.StudentExists(student.UserId, groupId)) { return(BadRequest("Пользователь уже добавлен")); } _groupService.AddStudent(student, group); await _db.SaveChangesAsync(); return(Ok(_mapper.Map <UserListDto>(student))); }
public int UpdateInquiry(Data.Models.Student student, Data.Models.Inquiry inquiry) { Data.Models.Student existingStudent = _studentRepository.Table.FirstOrDefault(w => w.Id == student.Id); if (existingStudent != null) { existingStudent.FirstName = student.FirstName; existingStudent.MiddleName = student.MiddleName; existingStudent.LastName = student.LastName; existingStudent.Gender = student.Gender; existingStudent.Address = student.Address; existingStudent.Mobile = student.Mobile; existingStudent.DOB = student.DOB; existingStudent.Email = student.Email; existingStudent.Remarks = student.Remarks; _studentRepository.Update(existingStudent); return(existingStudent.Id); } else { return(0); } }
public int Insert(Data.Models.Student student) { this._studentRepository.Insert(student); return(student.Id); }
protected void ClearData() { DepartmentIdString = ""; student = new Data.Models.Student(); }