public async Task <ActionResult> AddTranslation(ClassificationTranslation translation) { if (DoesClassificationExist(translation)) { ModelState.AddModelError("Value", ClassificationStrings.ValError_AlreadyExists); } if (ModelState.IsValid) { db.AddTranslation(translation); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } var c = await db.GetByIdAsync(translation.ClassificationId); if (c != null) { ViewBag.Languages = LanguageDefinitions .GenerateAvailableLanguageDDL(c.Translations.Select(t => t.LanguageCode).ToList()); } return(View(translation)); }
public async Task <ActionResult> AddTranslation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var e = await db.GetByIdAsync(id); if (e == null) { return(HttpNotFound()); } if (e.Translations.Count == LanguageDefinitions.Languages.Count) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL( e.Translations.Select(t => t.LanguageCode).ToArray()); return(View(new EventTranslation { EventId = e.Id })); }
public async Task <ActionResult> AddTranslation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var doc = await db.GetByIdAsync(id); if (doc == null) { return(HttpNotFound()); } var translations = doc.Translations .Select(dt => dt.LanguageCode) .ToList(); if (translations.Count() == LanguageDefinitions.Languages.Count) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var model = new DocumentTranslation { DocumentId = doc.Id }; ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL(doc.Translations.Select(t => t.LanguageCode).ToList()); return(View(model)); }
//public async Task<ActionResult> AddTranslation() public ActionResult AddTranslation() { var archive = db.Set <Archive>().FirstOrDefault(); var t = new ArchiveTranslation { ArchiveId = archive.Id }; ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL(archive.Translations.Select(tr => tr.LanguageCode)); return(View(t)); }
public async Task <ActionResult> AddTranslation(EventTranslation translation) { var author = await db.GetByIdAsync(translation.EventId); if (ModelState.IsValid) { author.Translations.Add(translation); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL( author.Translations.Select(t => t.LanguageCode).ToArray()); return(View(translation)); }
public async Task <ActionResult> AddTranslation(KeywordTranslation translation) { if (DoesKeywordExist(translation)) { ModelState.AddModelError("Value", KeywordStrings.Validation_AlreadyExists); } if (ModelState.IsValid) { db.AddTranslation(translation); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL( (await db.GetByIdAsync(translation.KeywordId)).Translations.Select(t => t.LanguageCode)); return(View(translation)); }
public async Task <ActionResult> AddTranslation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var c = await db.GetByIdAsync(id); if (c == null) { return(HttpNotFound()); } ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL(c.Translations.Select(t => t.LanguageCode).ToList()); return(View(new CollectionTranslation { CollectionId = c.Id })); }
public async Task <ActionResult> AddTranslation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var referencedLink = await db.GetByIdAsync(id); if (referencedLink == null) { return(HttpNotFound()); } ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL( referencedLink.Translations.Select(t => t.LanguageCode).ToArray()); return(View(new ReferencedLinkTranslation { Id = referencedLink.Id })); }
public async Task <ActionResult> AddTranslation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var image = await db.GetByIdAsync(id); if (image == null) { return(HttpNotFound()); } var model = new SpecimenTranslation { SpecimenId = image.Id }; ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL(image.Translations.Select(t => t.LanguageCode)); return(View(model)); }
public async Task <ActionResult> AddTranslation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var k = await db.GetByIdAsync(id); if (k == null) { return(HttpNotFound()); } ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL(k.Translations.Select(t => t.LanguageCode)); var model = new KeywordTranslation { KeywordId = k.Id }; return(View(model)); }