Esempio n. 1
0
 // GET: Group
 public JsonResult AddGroup(CompetencyGroup Group)
 {
     using (var context = new SSITrainingEntities())
     {
         string name = Group.GroupName;
         Group.CreateDateTime = DateTime.Now;
         Group.CreateUserId   = Convert.ToInt32(Session["USERID"]);
         context.CompetencyGroups.Add(Group);
         context.SaveChanges();
         return(Json(new { status = "Group Added Successfully!!" }));
     }
 }
Esempio n. 2
0
        public void DeleteGroup(CompetencyGroup group)
        {
            var compGroup = new CompetencyGroup {
                CompetencyGroupID = group.CompetencyGroupID
            };

            using (SSITrainingEntities context = new SSITrainingEntities())
            {
                context.CompetencyGroups.Attach(compGroup);
                context.CompetencyGroups.Remove(compGroup);
                context.SaveChanges();
            }
        }
Esempio n. 3
0
        public JsonResult EditGroup(CompetencyGroup updatedGroup)
        {
            CompetencyGroup group = new CompetencyGroup();
            string          status;

            using (SSITrainingEntities entity = new SSITrainingEntities())
            {
                var result = entity.CompetencyGroups.SingleOrDefault(g => g.CompetencyGroupID == updatedGroup.CompetencyGroupID);
                if (result != null)
                {
                    result.GroupName        = updatedGroup.GroupName;
                    result.ModifiedUserID   = 137;
                    result.ModifiedDateTime = DateTime.Now;
                    entity.SaveChanges();
                    status = "Group Updated";
                }
                else
                {
                    status = "Cannot update this group b/c it no longer exists.";
                }
            }
            return(Json(new { status }));
        }