Exemplo n.º 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();
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 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));
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 7
0
 public void Update(Group entity)
 {
     _context.Groups.Attach(entity);
     _context.Entry(entity).State = EntityState.Modified;
 }
Exemplo n.º 8
0
 public void Update(Subtitles entity)
 {
     _context.Entry(entity).State = EntityState.Modified;
     _context.SaveChanges();
 }
Exemplo n.º 9
0
 public void Update(TEntity item)
 {
     _context.Entry(item).State = EntityState.Modified;
     _context.SaveChanges();
 }