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 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 JsonNetResult GetInquiryById(int Id) { InquiryViewModel Inquiry = new InquiryViewModel(); Data.Models.Inquiry objInquiry = this._inquiryService.GetForId(Id); if (Inquiry != null) { Inquiry.Id = objInquiry.Id; Inquiry.Remark = objInquiry.Remark; Inquiry.DivisionId = objInquiry.DivisionId; Inquiry.SubjectId = objInquiry.SubjectId; } return(JsonNet(Inquiry, JsonRequestBehavior.AllowGet)); }
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.Inquiry inquiry) { this._inquiryRepository.Insert(inquiry); return(inquiry.Id); }