public async Task<ActionResult> AddTranslation(ImageTranslation translation) { if (ModelState.IsValid) { db.AddTranslation(translation); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(translation); }
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 ImageTranslation { ImageId = image.Id }; ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL(image.Translations.Select(t => t.LanguageCode)); return View(model); }