Beispiel #1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
Beispiel #2
0
        public async Task <ActionResult> AddInfo(Information model)
        {
            model.DateTime = DateTime.Now;
            if (model.Id == 0)
            {
                if (model.ButtonId.HasValue)
                {
                    NewsModel btn = await _context.NewsModel.FindAsync(model.ButtonId.Value);

                    btn?.ListInformation.Add(model);
                }
                else
                {
                    _context.Information.Add(model);
                }
            }
            else
            {
                Information old = await _context.Information.FirstOrDefaultAsync(r => r.Id == model.Id);

                if (old != null)
                {
                    _context.Entry(old).CurrentValues.SetValues(model);
                }
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction("AddPage", new { id = model.ButtonId }));
        }
Beispiel #3
0
        public async Task <ActionResult> SaveSurvey(SurveyModel model)
        {
            SurveyModel old = await _context.Survey.Include(r => r.ListOption).FirstOrDefaultAsync(r => r.Id == model.Id);

            if (old != null)
            {
                model.Language = DataConfig.Language.CodeLang;
                _context.Entry(old).CurrentValues.SetValues(model);
                old.ListOption.Clear();

                if (model.ListOption != null)
                {
                    old.ListOption.AddRange(model.ListOption);
                }
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction("Survey"));
        }
 public void Update(Order order)
 {
     db.Entry(order).State = EntityState.Modified;
 }
 public void Update(Country country)
 {
     db.Entry(country).State = EntityState.Modified;
 }
 public void Update(Tour tour)
 {
     db.Entry(tour).State = EntityState.Modified;
 }
 public void Update(Transport transport)
 {
     db.Entry(transport).State = EntityState.Modified;
 }
Beispiel #8
0
 public void Update(Picture picture)
 {
     db.Entry(picture).State = EntityState.Modified;
 }
Beispiel #9
0
 public void Update(DailyProgram dailyProgram)
 {
     db.Entry(dailyProgram).State = EntityState.Modified;
 }
Beispiel #10
0
 public void Update(T item)
 {
     tourAgencyContext.Entry(item).State = EntityState.Modified;
 }