Пример #1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
Пример #2
0
 public virtual void Delete(FileLink entityToDelete)
 {
     entityToDelete.Delete();
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
 }
        [ExcludeFromCodeCoverage] // the _db.Entry makes this borderline untestable
        public async Task <int> ProcessPlannedInspections(IEnumerable <PlannedInspection> plannedInspections,
                                                          Questionnaire questionnaire, string instructions)
        {
            foreach (var plannedInspection in plannedInspections)
            {
                plannedInspection.Questionnaire = questionnaire;
                plannedInspection.Instructions  = instructions;
                if (plannedInspection.Id != 0)
                {
                    _db.Entry(plannedInspection).State = EntityState.Modified;
                }
                else
                {
                    if (plannedInspection.EndTime != null)
                    {
                        await CreatePlannedInspection(
                            plannedInspection.Festival.Id,
                            plannedInspection.Questionnaire.Id,
                            plannedInspection.StartTime,
                            (DateTime)plannedInspection.EndTime,
                            plannedInspection.EventTitle,
                            plannedInspection.Employee.Id);
                    }
                }
            }

            return(await SaveChanges());
        }
Пример #4
0
 public void UpdateContactPerson(Contactpersoon contact)
 {
     using (FestispecContext context = new FestispecContext())
     {
         Contactpersoon toUpdate = context.Contactpersoon.Where(c => c.ContactpersoonID == contact.ContactpersoonID).FirstOrDefault();
         context.Entry(toUpdate).CurrentValues.SetValues(contact);
         context.SaveChanges();
     }
 }
Пример #5
0
 public void UpdateCustomer(Klant klant)
 {
     using (FestispecContext context = new FestispecContext())
     {
         Klant toUpdate = context.Klant.Where(c => c.KlantID == klant.KlantID).FirstOrDefault();
         context.Entry(toUpdate).CurrentValues.SetValues(klant);
         context.SaveChanges();
     }
 }
Пример #6
0
 public void UpdateAccount(Account account)
 {
     using (FestispecContext context = new FestispecContext())
     {
         Account toUpdate = context.Account.Where(c => c.AccountID == account.AccountID).FirstOrDefault();
         context.Entry(toUpdate).CurrentValues.SetValues(account);
         context.SaveChanges();
     }
 }
 public void UpdateInspectieFormulier(Inspectieformulier inspec)
 {
     using (FestispecContext context = new FestispecContext())
     {
         Inspectieformulier target = context.Inspectieformulier.Where(i => i.InspectieformulierID == inspec.InspectieformulierID).FirstOrDefault();
         context.Entry(target).CurrentValues.SetValues(inspec);
         context.SaveChanges();
     }
 }
Пример #8
0
 public void UpdateJob(Opdracht opdracht)
 {
     using (FestispecContext context = new FestispecContext())
     {
         Opdracht toUpdate = context.Opdracht.Where(c => c.OpdrachtID == opdracht.OpdrachtID).FirstOrDefault();
         context.Entry(toUpdate).CurrentValues.SetValues(opdracht);
         context.SaveChanges();
     }
 }
 public int UpdateQuestion(Vraag question)
 {
     using (FestispecContext context = new FestispecContext())
     {
         Vraag target = context.Vraag.Where(v => v.VraagID == question.VraagID).FirstOrDefault();
         context.Entry(target).CurrentValues.SetValues(question);
         context.SaveChanges();
         return(1);
     }
 }
 public void UpdateQuotation(Offerte quotation)
 {
     using (FestispecContext context = new FestispecContext())
     {
         Offerte toUpdate = context.Offerte.FirstOrDefault(q => q.OfferteID == quotation.OfferteID);
         quotation.Aanmaakdatum = toUpdate.Aanmaakdatum;
         context.Entry(toUpdate).CurrentValues.SetValues(quotation);
         context.SaveChanges();
     }
 }
        public void UpdateQuestionOrderInspectionForm(List <Vraag> newOrder)
        {
            using (FestispecContext context = new FestispecContext())
            {
                foreach (Vraag change in newOrder)
                {
                    Vraag target = context.Vraag.Where(i => i.VraagID == change.VraagID).FirstOrDefault();
                    context.Entry(target).CurrentValues.SetValues(change);
                }

                context.SaveChanges();
            }
        }