Beispiel #1
0
        public virtual void Update(T entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("Tried to update null entity!");
            }

            _entities.Attach(entity);
            _context.Entry(entity).State = EntityState.Modified;
            _context.SaveChanges();
        }
        public ActionResult <WordDto> Get(string word)
        {
            if (string.IsNullOrEmpty(word))
            {
                return(BadRequest());
            }

            word = HttpUtility.UrlDecode(word);

            var foundWord = context.Words.Include(w => w.Definitions)
                            .ThenInclude(d => d.SubDictionary)
                            .Include(w => w.Definitions)
                            .ThenInclude(d => d.WordClass)
                            .Include(w => w.Definitions)
                            .ThenInclude(d => d.Usages)
                            .Include(w => w.Phases)
                            .ThenInclude(p => p.Definitions)
                            .Include(w => w.WordForms)
                            //.Include(w => w.RelativeWords)
                            .FirstOrDefault(w => w.Content == word);

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

            // Using explicit loading improves performance
            context.Entry(foundWord).Collection(w => w.RelativeWords).Load();

            return(ModelToDto(foundWord));
        }
 public ActionResult Edit([Bind(Include = "ID,Name")] Language language)
 {
     if (ModelState.IsValid)
     {
         db.Entry(language).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(language));
 }
Beispiel #4
0
        public override bool Delete(int id)
        {
            Word w = GetOne(id);

            if (w.Translations != null)
            {
                w.Translations.Clear();
                _db.Entry(w).State = EntityState.Modified;
                _db.SaveChanges();
            }
            return(base.Delete(id));
        }
Beispiel #5
0
 public bool Update(T newRecord)
 {
     try
     {
         var old = GetOne(newRecord.ID);
         _db.Entry(old).CurrentValues.SetValues(newRecord);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #6
0
 public bool Update(IEntity newRecord)
 {
     try
     {
         //object id = newRecord.Id;
         //T old = GetOne((TKey)id);
         T old = GetOne(newRecord.Id);
         _db.Entry(old).CurrentValues.SetValues(newRecord);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Beispiel #7
0
 public void Update(Group entity)
 {
     _context.Groups.Attach(entity);
     _context.Entry(entity).State = EntityState.Modified;
 }
Beispiel #8
0
 public void Update(Subtitles entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     _context.SaveChanges();
 }
Beispiel #9
0
 public void Update(TEntity item)
 {
     _context.Entry(item).State = EntityState.Modified;
     _context.SaveChanges();
 }