コード例 #1
0
        public JsonResult DeleteClass(EPortal.Models.Class Class)
        {
            int result = 0;
            //string orgid = Session["OrgId"].ToString();
            string orgid = User.OrgId;

            string errormsg = string.Empty;

            // validation = EPortal.Utility.Utility.ValidateProperty(orgdata.Code, "Required");

            using (EPortalEntities entity = new EPortalEntities())
            {
                //var checkref = (from r in entity.Classes
                //                where r.OrganizationID == orgid
                //                && r.Id == Class.Id
                //                select r).FirstOrDefault();
                //if (checkref != null)
                //{
                //    errormsg = "Operation conflict:Operation cannot be performed.Record already in Used.";
                //}
                //else
                //{

                entity.Entry(Class).State = System.Data.Entity.EntityState.Deleted;
                result = entity.SaveChanges();
                //}
            }

            return(Json(new { result = result > 0 ? true : false, errormsg = errormsg }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult GetClassInfo(EPortal.Models.Class Class)
        {
            //string orgid = Session["OrgId"].ToString();

            string orgid = User.OrgId;

            RoleList roleinforole = new RoleList();

            using (EPortalEntities entity = new EPortalEntities())
            {
                roleinforole = (from o in entity.Classes
                                where o.Id == Class.Id &&
                                o.OrganizationID == orgid
                                select new RoleList
                {
                    Id = o.Id,
                    Code = o.Code,
                    Name = o.Name,
                    Operation = "Edit"
                }).FirstOrDefault();
            }
            return(Json(roleinforole, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public JsonResult SaveClass(EPortal.Models.Class classinfo)
        {
            string errormsg = "";
            int    result   = 0;

            //if ((role.Code != "" || role.Code != null) && (role.Name != "" || role.Name != null))
            {
                //string orgid = Session["OrgId"].ToString();

                string orgid = User.OrgId;

                using (EPortalEntities entity = new EPortalEntities())
                {
                    if (classinfo.Operation == "Create")
                    {
                        var checkrolecode = (from r in entity.RoleMasters
                                             where r.OrganizationID == orgid &&
                                             r.Code == classinfo.Code
                                             select r).FirstOrDefault();
                        if (checkrolecode == null)
                        {
                            classinfo.Id             = Guid.NewGuid().ToString();
                            classinfo.OrganizationID = orgid;
                            classinfo.RowState       = true;
                            classinfo.CreateDateTime = System.DateTime.Now;

                            entity.Entry(classinfo).State = System.Data.Entity.EntityState.Added;
                            entity.Classes.Add(classinfo);
                            try
                            {
                                result = entity.SaveChanges();
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        else
                        {
                            errormsg = "Class already exist with same Code.";
                        }
                    }
                    else
                    {
                        EPortal.Models.Class roledata = (from o in entity.Classes
                                                         where o.OrganizationID == orgid &&
                                                         o.Id == classinfo.Id
                                                         select o
                                                         ).FirstOrDefault();

                        roledata.Code = classinfo.Code;
                        roledata.Name = classinfo.Name;
                        entity.Entry(roledata).State = System.Data.Entity.EntityState.Modified;
                        try
                        {
                            result = entity.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            return(Json(new { result = result > 0 ? true : false, errormsg = errormsg }, JsonRequestBehavior.AllowGet));
        }