コード例 #1
0
        /// <summary>
        /// Removes a given contact from the repo.
        /// </summary>
        /// <param name="contact">Contact to remove.</param>
        public void Remove(InvoiceItem invoiceItem)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(invoiceItem).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
コード例 #2
0
        /// <summary>
        /// Tries to store (persist) data about a given user.
        /// </summary>
        /// <param name="user">User to be persisted in the repo.</param>
        public void Store(User user)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(user).State = ((user.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
コード例 #3
0
        /// <summary>
        /// Removes a given accountingCode from the repo.
        /// </summary>
        /// <param name="accountingCode">AccountingCode to remove.</param>
        public void Remove(AccountingCode accountingCode)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(accountingCode).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
コード例 #4
0
        /// <summary>
        /// Tries to store (persist) data about a given accountingCode.
        /// </summary>
        /// <param name="accountingCode">AccountingCode to be persisted in the repo.</param>
        public void Store(AccountingCode accountingCode)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(accountingCode).State = ((accountingCode.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
コード例 #5
0
        /// <summary>
        /// Removes a given statement from the repo.
        /// </summary>
        /// <param name="statement">Statement to remove.</param>
        public void Remove(Statement statement)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(statement).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
コード例 #6
0
        /// <summary>
        /// Removes a given receipt from the repo.
        /// </summary>
        /// <param name="receipt">Receipt to remove.</param>
        public void Remove(Receipt receipt)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(receipt).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
コード例 #7
0
        /// <summary>
        /// Tries to store (persist) data about a given journal.
        /// </summary>
        /// <param name="journal">Journal to be persisted in the repo.</param>
        public void Store(Journal journal)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(journal).State = ((journal.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
コード例 #8
0
        /// <summary>
        /// Removes a given journal from the repo.
        /// </summary>
        /// <param name="journal">Journal to remove.</param>
        public void Remove(Journal journal)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(journal).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
コード例 #9
0
        /// <summary>
        /// Tries to store (persist) data about a given contact.
        /// </summary>
        /// <param name="contact">Contact to be persisted in the repo.</param>
        public void Store(InvoiceItem invoiceItem)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(invoiceItem).State = ((invoiceItem.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
コード例 #10
0
        /// <summary>
        /// Removes a given user from the repo.
        /// </summary>
        /// <param name="user">User to remove.</param>
        public void Remove(User user)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(user).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
コード例 #11
0
        /// <summary>
        /// Tries to store (persist) data about a given statement.
        /// </summary>
        /// <param name="statement">Statement to be persisted in the repo.</param>
        public void Store(Statement statement)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(statement).State = ((statement.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
コード例 #12
0
        public Usuario UserLast(Usuario user)
        {
            var result = usuarios.FirstOrDefault(x => x.Nome == user.Nome && x.Password == user.Password);

            try
            {
                _context.Entry(result);
                _context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
コード例 #13
0
        public T Update(T entity)
        {
            var result = FindById(entity.Id);

            try
            {
                if (result != null)
                {
                    _context.Entry(result).CurrentValues.SetValues(entity);
                    _context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
コード例 #14
0
        public T Update(T item)
        {
            var result = dataSet.SingleOrDefault(i => i.Id.Equals(item.Id));

            if (result != null)
            {
                try
                {
                    _mysqlContext.Entry(result).CurrentValues.SetValues(item);
                    _mysqlContext.SaveChanges();
                    return(item);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
コード例 #15
0
        public T Update(T item)
        {
            if (!Exist(item.codigo))
            {
                return(null);
            }

            var result = dataset.SingleOrDefault(p => p.codigo.Equals(item.codigo));

            try
            {
                _context.Entry(result).CurrentValues.SetValues(item);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(item);
        }
コード例 #16
0
        public Book Update(Book book)
        {
            if (!Exist(book.id))
            {
                return(null);
            }

            var result = _repository.Books.SingleOrDefault(p => p.id.Equals(book.id));

            try
            {
                _repository.Entry(result).CurrentValues.SetValues(book);
                _repository.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(book);
        }
コード例 #17
0
        public Person Update(Person person)
        {
            if (!Exists(person.Id))
            {
                return(null);
            }

            var result = _context.People.SingleOrDefault(p => p.Id.Equals(person.Id));

            if (result != null)
            {
                try
                {
                    _context.Entry(result).CurrentValues.SetValues(person);
                    _context.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(person);
        }
コード例 #18
0
 public void Update(T obj)
 {
     context.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     context.SaveChanges();
 }