Пример #1
0
        public EventLog Create(EventLog eventLog)
        {
            if (eventLog == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(eventLog).State = EntityState.Added;
                db.SaveChanges();
            }

            return eventLog;
        }
Пример #2
0
        public bool Delete(EventLog eventLog)
        {
            if (eventLog == null) return false;

            using (var db = new DozpContext())
            {
                db.Entry(eventLog).State = EntityState.Deleted;
                db.SaveChanges();
            }

            return true;
        }
Пример #3
0
        public bool Delete(Institution institution)
        {
            if (institution == null) return false;

            using (var db = new DozpContext())
            {
                db.Entry(institution).State = EntityState.Deleted;
                db.SaveChanges();
            }

            return true;
        }
Пример #4
0
        public bool Delete(Book book)
        {
            if (book == null) return false;

            using (var db = new DozpContext())
            {
                db.Entry(book).State = EntityState.Deleted;
                db.SaveChanges();
            }

            return true;
        }
Пример #5
0
        public Institution Create(Institution institution)
        {
            if (institution == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(institution).State = EntityState.Added;
                db.SaveChanges();
            }

            return institution;
        }
Пример #6
0
        public Book Create(Book book)
        {
            if (book == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(book).State = EntityState.Added;
                db.SaveChanges();
            }

            return book;
        }
Пример #7
0
        public Operation Create(Operation operation)
        {
            if (operation == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(operation).State = EntityState.Added;
                db.SaveChanges();
            }

            return operation;
        }
Пример #8
0
        public ScanFile Create(ScanFile scanFile)
        {
            if (scanFile == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(scanFile).State = EntityState.Added;
                db.SaveChanges();
            }

            return scanFile;
        }
Пример #9
0
        public User Update(User user)
        {
            if (user == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
            }

            return user;
        }
Пример #10
0
        public Institution Update(Institution institution)
        {
            if (institution == null) return null;

            //try
            //{
            using (var db = new DozpContext())
            {
                db.Entry(institution).State = EntityState.Modified;
                db.SaveChanges();
            }
            //}
            //catch (DbEntityValidationException ex)
            //{
            //    StringBuilder sb = new StringBuilder();
            //    foreach (var result in ex.EntityValidationErrors)
            //    {
            //        sb.AppendLine(string.Format(ErrorMessage.ENTITY_VALIDATION_ERROR, result.Entry.Entity.GetType().Name, result.Entry.State));
            //        foreach (var error in result.ValidationErrors)
            //        {
            //            sb.AppendLine(String.Format(ErrorMessage.PROPERTY_VALIDATION_ERROR, error.PropertyName, error.ErrorMessage));
            //        }
            //    }
            //    throw new DbEntityValidationException(sb.ToString(), ex);
            //}

            return institution;
        }
Пример #11
0
        internal Operation Update(Operation operation)
        {
            if (operation == null) return null;

            using (var db = new DozpContext())
            {
                db.Entry(operation).State = EntityState.Modified;
                db.SaveChanges();
            }

            return operation;
        }
Пример #12
0
        internal bool Delete(Operation operation)
        {
            if (operation == null) return false;

            using (var db = new DozpContext())
            {
                db.Entry(operation).State = EntityState.Deleted;
                db.SaveChanges();
            }

            return true;
        }