Exemplo n.º 1
0
        public ActionResult AddChild(ParentModel Model)
        {
            string result = "Error";

            Model.IsActive  = "Y";
            Model.CreatedBy = "User1";
            Model.UserId    = "Parent1";


            //   var  item = Connection.tblParents.FirstOrDefault(i => i.UserId ==Model.UserId);
            if (Model.ParentId != null && Model.StudentId1 != null)
            {
                //  long  parentId = item.ParentId;
                long parentId = 2;
                //     Model.ParentId = parentId.ToString();
                long longP       = long.Parse(Model.ParentId);
                var  count       = Connection.tblParentStudents.Count(u => u.ParentId == longP && u.StudentId == Model.StudentId1);
                var  countparent = Connection.tblParentStudents.Count(u => u.StudentId == Model.StudentId1);

                if (count == 0)
                {
                    if (countparent < 3)
                    {
                        tblParentStudent tps = new tblParentStudent();
                        tps.CreatedBy   = "User1";
                        tps.CreatedDate = DateTime.Today;
                        tps.IsActive    = "Y";
                        //tps.ParentId = parentId;
                        tps.ParentId  = long.Parse(Model.ParentId);
                        tps.SchoolId  = Model.SchoolId;
                        tps.StudentId = Model.StudentId1;
                        Connection.tblParentStudents.Add(tps);
                        Connection.SaveChanges();


                        result = "sessioncheck" + "!" + Model.ParentId + "!" + Model.SchoolId;
                    }
                    else
                    {
                        result = "maxp";
                    }
                }
                else
                {
                    result = "Exits";
                }
            }
            else
            {
                result = "fill";
            }
            //ShowTeacherQualificatoin();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult DeleteChild(ParentModel Model)
        {
            try
            {
                long ParentId = long.Parse(Model.ParentId);
                var  item     = Connection.tblParentStudents.FirstOrDefault(i => i.ParentId == ParentId && i.StudentId == Model.StudentId);

                tblParentStudent Tble = Connection.tblParentStudents.Find(item.SeqNo);

                Connection.tblParentStudents.Remove(Tble);
                Connection.SaveChanges();


                return(Json(Model.ParentId, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index");
            }
            catch
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
        }