public static void Insert(GanttResourceAssignmentModel assignment)
        {
            if (!UpdateDatabase)
            {
                var first = All().OrderByDescending(a => a.ID).FirstOrDefault();
                var id = 0;

                if (first != null)
                {
                    id = first.ID;
                }

                assignment.ID = id + 1;

                All().Add(assignment);
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    var entity = assignment.ToEntity();

                    db.GanttResourceAssignments.AddObject(entity);

                    db.SaveChanges();
                }
            }
        }
        public static void Insert(GanttResourceAssignmentModel assignment)
        {
            if (!UpdateDatabase)
            {
                var first = All().OrderByDescending(a => a.ID).FirstOrDefault();
                var id    = 0;

                if (first != null)
                {
                    id = first.ID;
                }

                assignment.ID = id + 1;

                All().Add(assignment);
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    var entity = assignment.ToEntity();

                    db.GanttResourceAssignments.AddObject(entity);

                    db.SaveChanges();
                }
            }
        }
        public static void Delete(GanttResourceAssignmentModel assigment)
        {
            if (!UpdateDatabase)
            {
                var target = One(a => a.ID == assigment.ID);
                if (target != null)
                {
                    All().Remove(target);
                }
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    var entity = assigment.ToEntity();
                    db.GanttResourceAssignments.Attach(entity);

                    db.GanttResourceAssignments.DeleteObject(entity);

                    db.SaveChanges();
                }
            }
        }
        public static void Update(GanttResourceAssignmentModel assigment)
        {
            if (!UpdateDatabase)
            {
                var target = One(a => a.ID == assigment.ID);

                if (target != null)
                {
                    target.Units = assigment.Units;
                }
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    var entity = assigment.ToEntity();

                    db.GanttResourceAssignments.Attach(entity);
                    db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);

                    db.SaveChanges();
                }
            }
        }
        public static void Update(GanttResourceAssignmentModel assigment)
        {
            if (!UpdateDatabase)
            {
                var target = One(a => a.ID == assigment.ID);

                if (target != null)
                {
                    target.Units = assigment.Units;
                }
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    var entity = assigment.ToEntity();

                    db.GanttResourceAssignments.Attach(entity);
                    db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);

                    db.SaveChanges();
                }
            }
        }
        public static void Delete(GanttResourceAssignmentModel assigment)
        {
            if (!UpdateDatabase)
            {
                var target = One(a => a.ID == assigment.ID);
                if (target != null)
                {
                    All().Remove(target);
                }
            }
            else
            {
                using (var db = new SampleEntities())
                {
                    var entity = assigment.ToEntity();
                    db.GanttResourceAssignments.Attach(entity);

                    db.GanttResourceAssignments.DeleteObject(entity);

                    db.SaveChanges();
                }
            }
        }