Пример #1
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult EditRecord(string Details, string Master)
        {
            try
            {
                dynamic master  = JsonConvert.DeserializeObject(Master);
                dynamic details = JsonConvert.DeserializeObject(Details);

                int ClassID = 0;

                foreach (var m in master)
                {
                    ClassID = Convert.ToInt32(m._ClassID);
                    tblClassMst cls = db.tblClassMst.Find(ClassID);
                    cls.ClassName    = m._ClassName;
                    cls.StageID      = m._StageID;
                    cls.Prefix       = m._Prefix;
                    cls.IsActive     = m._IsAcive;
                    cls.IsDarsgah    = m._risdarasgah;
                    cls.GenerateFees = m._generatefees;
                    cls.SchoolID     = portalutilities._schollid;
                    cls.CreateDate   = portalutilities._GetDate;
                    cls.CreateBy     = portalutilities._username;
                    cls.IsDelete     = false;
                    db.tblClassMst.Add(cls);
                    db.Entry(cls).State = EntityState.Modified;
                    db.SaveChanges();
                    ClassID = cls.ClassID;
                }


                //  List<tblClassDtl> cld1 = new List<tblClassDtl>();
                // tblClassDtl cld = new tblClassDtl();
                int sectionid = 0;
                foreach (var d in details)
                {
                    if (d._SectionID > 0)
                    {
                        sectionid = Convert.ToInt32(d._SectionID);
                        tblClassDtl cld = db.tblClassDtl.Where(a => a.SectionID == sectionid && a.ClassID == ClassID).FirstOrDefault();
                        cld.ClassID   = ClassID;
                        cld.SectionID = d._SectionID;
                        db.tblClassDtl.Add(cld);
                        if (cld != null)
                        {
                            db.Entry(cld).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        else
                        {
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch
            {
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        // GET: /Class/Details/5

        public ActionResult Save(string Details, string Master)
        {
            try
            {
                dynamic master  = JsonConvert.DeserializeObject(Master);
                dynamic details = JsonConvert.DeserializeObject(Details);

                tblClassMst cls = new tblClassMst();
                foreach (var m in master)
                {
                    cls.ClassName    = m._ClassName;
                    cls.StageID      = m._StageID;
                    cls.Prefix       = m._Prefix;
                    cls.IsActive     = m._IsAcive;
                    cls.IsDarsgah    = m._risdarasgah;
                    cls.GenerateFees = m._generatefees;
                    cls.SchoolID     = portalutilities._schollid;
                    cls.CreateDate   = portalutilities._GetDate;
                    cls.CreateBy     = portalutilities._username;
                    cls.IsDelete     = false;
                    db.tblClassMst.Add(cls);
                    db.SaveChanges();
                }

                int ClassID = cls.ClassID;
                //  List<tblClassDtl> cld1 = new List<tblClassDtl>();
                tblClassDtl cld = new tblClassDtl();
                foreach (var d in details)
                {
                    if (d._SectionID > 0)
                    {
                        cld.ClassID   = ClassID;
                        cld.SectionID = d._SectionID;
                        db.tblClassDtl.Add(cld);
                    }
                }
                db.SaveChanges();
            }
            catch
            {
            }
            return(RedirectToAction("Index"));
        }