public virtual void Update(ResourceAssignmentViewModel assignment)
        {
            if (!UpdateDatabase)
            {
                var assignments = GetAll();
                var target      = assignments.FirstOrDefault(e => e.ID == assignment.ID);

                if (target != null)
                {
                    target.ResourceID = assignment.ResourceID;
                    target.TaskID     = assignment.TaskID;
                    target.Units      = assignment.Units;
                }

                Session.SetObjectAsJson("GanttAssignments", assignments);
            }
            else
            {
                using (var db = GetContext())
                {
                    var entity = assignment.ToEntity();

                    db.GanttResourceAssignments.Attach(entity);
                    db.Entry(entity).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
        }
        public virtual void Insert(ResourceAssignmentViewModel assignment)
        {
            if (!UpdateDatabase)
            {
                var assignments = GetAll();
                var first       = assignments.OrderByDescending(e => e.ID).FirstOrDefault();
                var id          = (first != null) ? first.ID : 0;

                assignment.ID = id + 1;

                assignments.Insert(0, assignment);

                Session.SetObjectAsJson("GanttAssignments", assignments);
            }
            else
            {
                using (var db = GetContext())
                {
                    var entity = assignment.ToEntity();

                    db.GanttResourceAssignments.Add(entity);
                    db.SaveChanges();

                    assignment.ID = entity.ID;
                }
            }
        }
        public virtual void Delete(ResourceAssignmentViewModel assignment)
        {
            if (!UpdateDatabase)
            {
                var assignments = GetAll();
                var target      = assignments.FirstOrDefault(e => e.ID == assignment.ID);

                if (target != null)
                {
                    assignments.Remove(target);
                }

                Session.SetObjectAsJson("GanttAssignments", assignments);
            }
            else
            {
                using (var db = GetContext())
                {
                    var entity = assignment.ToEntity();

                    db.GanttResourceAssignments.Attach(entity);
                    db.GanttResourceAssignments.Remove(entity);
                    db.SaveChanges();
                }
            }
        }
Exemple #4
0
        public virtual void Delete(ResourceAssignmentViewModel assignment)
        {
            var entity = assignment.ToEntity();

            db.GanttResourceAssignments.Attach(entity);
            db.GanttResourceAssignments.Remove(entity);
            db.SaveChanges();
        }
Exemple #5
0
        public virtual void Update(ResourceAssignmentViewModel assignment)
        {
            var entity = assignment.ToEntity();

            db.GanttResourceAssignments.Attach(entity);
            db.Entry(entity).State = EntityState.Modified;
            db.SaveChanges();
        }
Exemple #6
0
        public virtual void Insert(ResourceAssignmentViewModel assignment)
        {
            var entity = assignment.ToEntity();

            db.GanttResourceAssignments.Add(entity);
            db.SaveChanges();

            assignment.ID = entity.ID;
        }