Ejemplo n.º 1
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult EditRecord(string Details, string Master)
        {
            try
            {
                dynamic master  = JsonConvert.DeserializeObject(Master);
                dynamic details = JsonConvert.DeserializeObject(Details);

                int MSID = 0;
                foreach (var m in master)
                {
                    int      id   = Convert.ToInt32(m._RoleID);
                    tblRoles role = db.tblRoles.Find(id);
                    role.RoleName = m._RoleName;
                    role.IsActive = m._IsActive;

                    db.tblRoles.Add(role);
                    db.Entry(role).State = EntityState.Modified;
                    MSID = role.RoleID;
                }
                db.SaveChanges();

                foreach (var d in details)
                {
                    int       id   = Convert.ToInt32(d._RightID);
                    tblRights form = db.tblRights.Find(id);

                    form.RoleID          = MSID;
                    form.FormID          = d._formid;
                    form.IsView          = d._isview;
                    form.IsSave          = d._issave;
                    form.IsUpdate        = d._isupdate;
                    form.IsDelete        = d._isdelete;
                    form.IsPrint         = d._isprint;
                    form.IsRestore       = d._isrestore;
                    db.Entry(form).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            catch
            {
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        // GET: /Roles/

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

                tblRoles role = new tblRoles();
                foreach (var m in master)
                {
                    role.RoleName   = m._RoleName;
                    role.CreateDate = portalutilities._GetDate;
                    role.CreateBy   = portalutilities._username;
                    role.IsDelete   = false;
                    role.IsActive   = m._IsAcive;
                    role.SchoolID   = portalutilities._schollid;
                    role.IsDelete   = false;
                    db.tblRoles.Add(role);
                }
                db.SaveChanges();
                int RoleID = role.RoleID;


                foreach (var d in details)
                {
                    tblRights rights = new tblRights();
                    rights.RoleID    = RoleID;
                    rights.FormID    = d._formid;
                    rights.IsView    = d._isview;
                    rights.IsSave    = d._issave;
                    rights.IsUpdate  = d._isupdate;
                    rights.IsDelete  = d._isdelete;
                    rights.IsPrint   = d._isprint;
                    rights.IsRestore = d._isrestore;
                    db.tblRights.Add(rights);
                }
                db.SaveChanges();
            }
            catch
            {
            }
            return(RedirectToAction("Index"));
        }