コード例 #1
0
        public void Delete(int id)
        {
            var user = _context.Users.Find(id);

            if (user == null)
            {
            }

            _context.Users.Remove(user);
            _context.SaveChanges();
        }
コード例 #2
0
 public Person Create(Person person)
 {
     try
     {
         _context.Add(person);
         _context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
     return(person);
 }
コード例 #3
0
 public Book CreateBook(Book book)
 {
     try
     {
         _dataset.Add(book);
         _context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
     return(book);
 }
コード例 #4
0
 public Cuddly Create(Cuddly Cuddly)
 {
     try
     {
         _dataset.Add(Cuddly);
         _context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
     return(Cuddly);
 }
コード例 #5
0
 public Usuario Newuser(Usuario user)
 {
     try
     {
         usuarios.Add(user);
         _context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
     return(user);
 }
コード例 #6
0
 public T Create(T entity)
 {
     try
     {
         _dataSet.Add(entity);
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(entity);
 }
コード例 #7
0
 public T Create(T item)
 {
     try
     {
         dataSet.Add(item);
         _mysqlContext.SaveChanges();
         return(item);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #8
0
        public Book Create(Book book)
        {
            try
            {
                _repository.Add(book);
                _repository.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(book);
        }
コード例 #9
0
        public T CriarNovo(T item)
        {
            try
            {
                dataset.Add(item);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(item);
        }
コード例 #10
0
 public NormalComment CreateNormalComment(NormalComment normalComment)
 {
     _normalCommentRepository.Insert(normalComment);
     _mysqlContext.SaveChanges();
     _memoryCache.Remove(RBMemCacheKeys.NORMALCOMMENTKEY + normalComment.BlogId.ToString());
     _memoryCache.Remove(RBMemCacheKeys.NORMALCOMMENTKEY + "0");
     return(normalComment);
 }
コード例 #11
0
        /// <summary>
        /// Adds a new contact to the repo.
        /// </summary>
        /// <param name="contact">Contact to add.</param>
        public void Add(Contact contact)
        {
            using (var context = new MysqlContext())
            {
                context.Contacts.Add(contact);

                context.SaveChanges();
            }
        }
コード例 #12
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();
            }
        }
コード例 #13
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();
            }
        }
コード例 #14
0
        /// <summary>
        /// Adds a new contact to the repo.
        /// </summary>
        /// <param name="contact">Contact to add.</param>
        public void Add(InvoiceItem invoiceItem)
        {
            using (var context = new MysqlContext())
            {
                context.InvoiceItems.Add(invoiceItem);

                context.SaveChanges();
            }
        }
コード例 #15
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();
            }
        }
コード例 #16
0
        /// <summary>
        /// Adds a new accountingCode to the repo.
        /// </summary>
        /// <param name="accountingCode">AccountingCode to add.</param>
        public void Add(AccountingCode accountingCode)
        {
            using (var context = new MysqlContext())
            {
                context.AccountingCodes.Add(accountingCode);

                context.SaveChanges();
            }
        }
コード例 #17
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();
            }
        }
コード例 #18
0
        /// <summary>
        /// Adds a new journal to the repo.
        /// </summary>
        /// <param name="journal">Journal to add.</param>
        public void Add(Journal journal)
        {
            using (var context = new MysqlContext())
            {
                context.Journals.Add(journal);

                context.SaveChanges();
            }
        }
コード例 #19
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();
            }
        }
コード例 #20
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();
            }
        }
コード例 #21
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();
            }
        }
コード例 #22
0
        /// <summary>
        /// Adds a new statement to the repo.
        /// </summary>
        /// <param name="statement">Statement to add.</param>
        public void Add(Statement statement)
        {
            using (var context = new MysqlContext())
            {
                context.Statements.Add(statement);

                context.SaveChanges();
            }
        }
コード例 #23
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();
            }
        }
コード例 #24
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();
            }
        }
コード例 #25
0
        /// <summary>
        /// Adds a new receipt to the repo.
        /// </summary>
        /// <param name="receipt">Receipt to add.</param>
        public void Add(Receipt receipt)
        {
            using (var context = new MysqlContext())
            {
                context.Receipts.Add(receipt);

                context.SaveChanges();
            }
        }
コード例 #26
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();
            }
        }
コード例 #27
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();
            }
        }
コード例 #28
0
        /// <summary>
        /// Adds a new user to the repo.
        /// </summary>
        /// <param name="user">User to add.</param>
        public void Add(User user)
        {
            using (var context = new MysqlContext())
            {
                context.Users.Add(user);

                context.SaveChanges();
            }
        }
コード例 #29
0
        public async Task <IActionResult> StatusInProgress(long id)
        {
            var interv = _context.interventions.Find(id);

            if (interv == null)
            {
                return(NotFound());
            }

            interv.status            = "InProgress";
            interv.start_date_interv = DateTime.Now;

            _context.interventions.Update(interv);
            _context.SaveChanges();
            var json = new JObject();

            json["message"] = "The status of intervention id: " + interv.id + " has been modified to " + interv.status;
            return(Content(json.ToString(), "application/json"));
        }
        public async Task <IActionResult> PutInProgress(long id)
        {
            var INTER = _context.interventions.Find(id);

            if (INTER == null)
            {
                return(NotFound());
            }

            INTER.status             = "InProgress";
            INTER.start_intervention = DateTime.Now;

            _context.interventions.Update(INTER);
            _context.SaveChanges();
            var json = new JObject();

            json["message"] = "the change of status is well done";
            return(Content(json.ToString(), "application/json"));
        }