public virtual void Delete(DependencyViewModel dependency)
        {
            if (!UpdateDatabase)
            {
                var dependencies = GetAll();
                var target       = dependencies.FirstOrDefault(p => p.DependencyID == dependency.DependencyID);

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

                Session.SetObjectAsJson("GanttDependencies", dependencies);
            }
            else
            {
                using (var db = GetContext())
                {
                    var entity = dependency.ToEntity();
                    db.GanttDependencies.Attach(entity);
                    db.GanttDependencies.Remove(entity);
                    db.SaveChanges();
                }
            }
        }
        public virtual void Insert(DependencyViewModel dependency)
        {
            if (!UpdateDatabase)
            {
                var dependencies = GetAll();
                var first        = dependencies.OrderByDescending(e => e.DependencyID).FirstOrDefault();
                var id           = (first != null) ? first.DependencyID : 0;

                dependency.DependencyID = id + 1;

                dependencies.Insert(0, dependency);

                Session.SetObjectAsJson("GanttDependencies", dependencies);
            }
            else
            {
                using (var db = GetContext())
                {
                    var entity = dependency.ToEntity();

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

                    dependency.DependencyID = entity.ID;
                }
            }
        }
Exemplo n.º 3
0
        public virtual void Delete(DependencyViewModel dependency, ModelStateDictionary modelState)
        {
            var entity = dependency.ToEntity();

            db.GanttDependencies.Attach(entity);
            db.GanttDependencies.Remove(entity);
            db.SaveChanges();
        }
Exemplo n.º 4
0
        public virtual void Update(DependencyViewModel dependency, ModelStateDictionary modelState)
        {
            var entity = dependency.ToEntity();

            db.GanttDependencies.Attach(entity);
            db.Entry(entity).State = EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 5
0
        public virtual void Insert(DependencyViewModel dependency, ModelStateDictionary modelState)
        {
            var entity = dependency.ToEntity();

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

            dependency.DependencyID = entity.ID;
        }