public JsonResult AddStudentPrevSchoolDetails(Student_Prev_School_Details stuPrevSchoolDetail)
        {
            stuPrevSchoolDetail.Created_On    = DateTime.Now;
            stuPrevSchoolDetail.Academic_Year = GetAcademicYear();
            stuPrevSchoolDetail.Is_Active     = true;
            List <Student_PrevSchoolList_ViewModel> addedStudentPrevSchoolDetails = new List <Student_PrevSchoolList_ViewModel>();

            addedStudentPrevSchoolDetails = GetStudentPrevSchoolDetails(stuPrevSchoolDetail);
            return(Json(new { items = addedStudentPrevSchoolDetails }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public async Task <ActionResult> AddPrevSchools(string schoolId, string RefSibling_Id, string Name, string Address, string AcYear, string FrmYear, string ToYear, string Leaving, string Comments)
        {
            var        userId = LoggedInUser.Id;
            JsonResult result = new JsonResult();

            try
            {
                var schoolid  = Convert.ToInt32(schoolId);
                var studentId = Convert.ToInt32(RefSibling_Id);
                var acYear    = Convert.ToInt32(AcYear);
                var frmYear   = Convert.ToInt32(FrmYear);
                var toYear    = Convert.ToInt32(ToYear);
                //   , string FrmYear, string ToYear, string Leaving, string Comments

                var CheckStudent = db.Student_Prev_School_Details.Where(a => a.Student_Id == studentId && a.School_Id == schoolid).Count();

                if (CheckStudent == 0)
                {
                    Student_Prev_School_Details addSchool = new Student_Prev_School_Details();
                    addSchool.Student_Id           = studentId;
                    addSchool.School_Id            = schoolid;
                    addSchool.Other_School_Name    = Name;
                    addSchool.Other_School_Address = Address;
                    addSchool.Academic_Year        = acYear;
                    addSchool.From_Year            = frmYear;
                    addSchool.To_Year        = toYear;
                    addSchool.Leaving_Reason = Leaving;
                    addSchool.Comments       = Comments;
                    addSchool.Created_On     = DateTime.Now;
                    addSchool.Created_By     = userId;
                    addSchool.Is_Active      = true;

                    db.Student_Prev_School_Details.Add(addSchool);
                    await db.SaveChangesAsync();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                result.Data = new { Result = "ERROR", Message = " This property already available in this block " };
            }

            return(RedirectToAction("SaveAndContiune"));
        }
        public List <Student_PrevSchoolList_ViewModel> GetStudentPrevSchoolDetails(Student_Prev_School_Details stuPrevSchoolDetail)
        {
            long nAcademicYear = GetAcademicYear();
            long nStudent_Id   = Convert.ToInt64(TempData.Peek("Student_Id"));

            stuPrevSchoolDetail.Student_Id = nStudent_Id;
            List <Student_PrevSchoolList_ViewModel> addedStudentPrevSchoolDetails = new List <Student_PrevSchoolList_ViewModel>();

            try
            {
                using (var dbcontext = new SchoolERPDBContext())
                {
                    dbcontext.Student_Prev_School_Detail.Add(stuPrevSchoolDetail);
                    dbcontext.SaveChanges();
                }

                using (var dbcontext = new SchoolERPDBContext())
                {
                    addedStudentPrevSchoolDetails = (from school in dbcontext.School
                                                     join prevSchooldetails in dbcontext.Student_Prev_School_Detail on school.Id equals prevSchooldetails.School_Id
                                                     where prevSchooldetails.Student_Id == nStudent_Id && prevSchooldetails.Academic_Year == nAcademicYear && prevSchooldetails.Is_Deleted == null || prevSchooldetails.Is_Deleted == false
                                                     select new Student_PrevSchoolList_ViewModel
                    {
                        Id = prevSchooldetails.Student_PrevSchool_Id,
                        Name = school.Name,
                        From_Year = prevSchooldetails.From_Year,
                        To_Year = prevSchooldetails.To_Year,
                        Leaving_Reason = prevSchooldetails.Leaving_Reason,
                        Updated_On = prevSchooldetails.Updated_On,
                        Student_Id = prevSchooldetails.Student_Id,
                        Comments = prevSchooldetails.Comments
                    }).ToList();
                }
            }
            catch (Exception ex)
            {
            }

            return(addedStudentPrevSchoolDetails);
        }
Example #4
0
        public async Task <ActionResult> DeletePrevSchools(string schoolId, string StudentId)
        {
            var        userId = LoggedInUser.Id;
            JsonResult result = new JsonResult();

            try
            {
                var school_Id  = Convert.ToInt32(schoolId);
                var student_Id = Convert.ToInt32(StudentId);
                Student_Prev_School_Details deletePrevSchool = db.Student_Prev_School_Details.Where(a => a.School_Id == school_Id && a.Student_Id == student_Id).FirstOrDefault();
                db.Entry(deletePrevSchool).CurrentValues.SetValues(deletePrevSchool);
                deletePrevSchool.Is_Deleted      = true;
                db.Entry(deletePrevSchool).State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                result.Data = new { Result = "ERROR", Message = " This property already available in this block " };
            }

            return(RedirectToAction("SaveAndContiune"));
        }