public ActionResult EditLanguage(Language language) { dbContext.Entry(language).State = EntityState.Modified; dbContext.SaveChanges(); Session["LanguageMessage"] = "Язык успешно изменен."; return(RedirectToAction("ListLanguages")); }
public void updateTranslation(string id) { //добавление новых слов из template в язык var templatesId = dbContext.Template.Select(t => t.TemplateId).ToList(); var translationsId = dbContext.Translations.Where(t => t.LanguageId == id).Select(t => t.MessageId).ToList(); foreach (var template in templatesId) { if (!translationsId.Contains(template)) { Translation translation = new Translation(); translation.LanguageId = id; translation.MessageId = template; translation.MessageTranslation = null; translation.LanguageNativeName = dbContext.Languages.Find(id).LanguageNativeName; dbContext.Translations.Add(translation); } } //dbContext.SaveChanges(); //удаление неиспользуемых слов foreach (var translation in translationsId) { if (!templatesId.Contains(translation)) { Translation deleteTranslation = dbContext.Translations.Find(id, translation); dbContext.Entry(deleteTranslation).State = EntityState.Deleted; } } dbContext.SaveChanges(); }
public async Task <IActionResult> AddWord(Words obj) { try { if (ModelState.IsValid) { if (obj.Id == 0) { obj.AddedTime = DateTime.Now; await _context.Words.AddAsync(obj); await _context.SaveChangesAsync(); } else { _context.Entry(obj).State = EntityState.Modified; await _context.SaveChangesAsync(); } return(RedirectToAction("List")); } return(View(obj)); } catch (Exception) { return(RedirectToAction("List")); } }
public void Update(Mistake item) { db.Entry(item).State = EntityState.Modified; }
public void Update(Topic item) { db.Entry(item).State = EntityState.Modified; }
public void Update(TopicResult item) { db.Entry(item).State = (Microsoft.EntityFrameworkCore.EntityState)EntityState.Modified; }
public void Update(Word item) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); }