Beispiel #1
0
        public JsonResult DeleteCourse(EPortal.Models.Course course)
        {
            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())
            {
                entity.Entry(course).State = System.Data.Entity.EntityState.Deleted;
                result = entity.SaveChanges();
            }

            return(Json(new { result = result > 0 ? true : false, errormsg = errormsg }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public JsonResult GetCourseInfo(EPortal.Models.Course course)
        {
            //string orgid = Session["OrgId"].ToString();

            string orgid = User.OrgId;

            RoleList roleinforole = new RoleList();

            using (EPortalEntities entity = new EPortalEntities())
            {
                roleinforole = (from o in entity.Courses
                                where o.Id == course.Id &&
                                o.OrganizationID == orgid
                                select new RoleList
                {
                    Id = o.Id,
                    Code = o.Code,
                    Name = o.Name,
                    Operation = "Edit"
                }).FirstOrDefault();
            }
            return(Json(roleinforole, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public JsonResult SaveCourse(EPortal.Models.Course course)
        {
            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 (course.Operation == "Create")
                    {
                        var checkrolecode = (from r in entity.RoleMasters
                                             where r.OrganizationID == orgid &&
                                             r.Code == course.Code
                                             select r).FirstOrDefault();
                        if (checkrolecode == null)
                        {
                            course.Id             = Guid.NewGuid().ToString();
                            course.OrganizationID = orgid;
                            course.RowState       = true;
                            course.CreateDateTime = System.DateTime.Now;

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

                        roledata.Code = course.Code;
                        roledata.Name = course.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));
        }