public int UpdateStudProgram(Data.Models.StudentProgram studentprogram, out int errorCode)
        {
            errorCode = 0;
            if (this._studentProgramRepository.Table.Any(a => a.StudentId == studentprogram.StudentId && a.DivisionId == studentprogram.DivisionId && a.SubjectId == studentprogram.SubjectId && a.Id == studentprogram.Id))
            {
                errorCode = 101;
                return(0);
            }

            Data.Models.StudentProgram existingProgram = _studentProgramRepository.Table.FirstOrDefault(w => w.Id == studentprogram.Id);

            if (existingProgram != null)
            {
                existingProgram.SubjectId  = studentprogram.SubjectId;
                existingProgram.DivisionId = studentprogram.DivisionId;
                existingProgram.FeeId      = studentprogram.FeeId;
                existingProgram.BatchId    = studentprogram.BatchId;
                _studentProgramRepository.Update(existingProgram);

                return(existingProgram.Id);
            }
            else
            {
                return(0);
            }
        }
        public JsonNetResult UpdateProgram(Data.Models.StudentProgram studentprogram)
        {
            JsonResponse response = new JsonResponse();

            try
            {
                int errorCode        = 0;
                int studentProgramId = this._studentprogramService.UpdateStudProgram(studentprogram, out errorCode);
                if (errorCode == 101)
                {
                    response.Status  = ResponseStatus.Warning;
                    response.Message = "Student already registered with same division and subject.";
                }
                else
                {
                    response.Data    = new { StudentProgramId = studentProgramId };
                    response.Status  = ResponseStatus.Success;
                    response.Message = "Registration successfully.";
                }
            }
            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 int Insert(Data.Models.StudentProgram StudentProgram, out int errorCode)
        {
            errorCode = 0;
            if (this._studentProgramRepository.Table.Any(a => a.StudentId == StudentProgram.StudentId && a.SubjectId == StudentProgram.SubjectId && a.DivisionId == StudentProgram.DivisionId))
            {
                errorCode = 101;
                return(0);
            }

            this._studentProgramRepository.Insert(StudentProgram);
            return(StudentProgram.Id);
        }
        public JsonNetResult GetProgramById(int Id)
        {
            Data.Models.StudentProgram objProgram = this._studentprogramService.GetProgramId(Id);
            StudentProgramViewModel    program    = new StudentProgramViewModel();

            if (program != null)
            {
                program.Id         = objProgram.Id;
                program.StudentId  = objProgram.StudentId;
                program.DivisionId = objProgram.DivisionId;
                program.SubjectId  = objProgram.SubjectId;
                program.BatchId    = objProgram.BatchId;
                program.FeeId      = objProgram.FeeId;
            }
            return(JsonNet(program, 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));
        }