Esempio n. 1
0
        public string UpdateTask(CompetencyTask compTask)
        {
            // var result = (int?)null;
            string result = "";

            try
            {
                // CompetencyTask cTask = new CompetencyTask();
                using (var context = new SSITrainingEntities())
                {
                    compTask.ModifiedDateTime = DateTime.Now;
                    compTask.ModifiedUserID   = Convert.ToInt32(Session["USERID"]);
                    context.CompetencyTasks.Attach(compTask);

                    var entry = context.Entry(compTask);
                    entry.Property(t => t.Task).IsModified             = true;
                    entry.Property(t => t.ModifiedUserID).IsModified   = true;
                    entry.Property(t => t.ModifiedDateTime).IsModified = true;
                    entry.Property(t => t.Sort).IsModified             = true;
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                result = "Task Update Failed";
                Console.WriteLine(result);
            }
            return(result);
        }
Esempio n. 2
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. 3
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. 4
0
        public JsonResult AddTask(CompetencyTask compTask)
        {
            try {
                // CompetencyTask cTask = new CompetencyTask();
                using (var context = new SSITrainingEntities())
                {
                    compTask.Sort           = GetTaskMaxSort(compTask.CompDefHeaderID);
                    compTask.CreateDateTime = DateTime.Now;
                    compTask.CreateUserID   = Convert.ToInt32(Session["USERID"]);

                    context.CompetencyTasks.Add(compTask);
                    context.SaveChanges();
                    return(Json(new { status = "Task Added Successfully!!" }));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(Json(new { status = ex.Message }));
            }
        }
Esempio n. 5
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 }));
        }