// GET: BackOffice/Processes/Create public ActionResult Create() { var model = new ProcessTranslation { LanguageCode = LanguageDefinitions.DefaultLanguage }; return View(model); }
public async Task<ActionResult> Create(ProcessTranslation pt) { if (DoesProcessExist(pt)) { ModelState.AddModelError("Value", ProcessStrings.Validation_AlreadyExists); } if (ModelState.IsValid) { var process = new Process(); process.Translations.Add(pt); db.Add(process); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(pt); }
public async Task<ActionResult> AuxAdd(ProcessTranslation t) { var cl = db.Entities .FirstOrDefault(c => c.Translations.Any(ct => ct.LanguageCode == t.LanguageCode && ct.Value == t.Value && ct.ProcessId != t.ProcessId) ); if (cl == null) { cl = new Process(); cl.Translations.Add(t); db.Add(cl); await db.SaveChangesAsync(); } return Json((await db.Entities .OrderBy(ct => ct.Id) .ToListAsync()) .Select(ct => new TranslatedViewModel<Process, ProcessTranslation>(ct)) .Select(ct => new { value = ct.Entity.Id.ToString(), text = ct.Translation.Value, selected = ct.Entity.Id == cl.Id }) .ToList()); }
public ActionResult AuxAdd() { var model = new ProcessTranslation { LanguageCode = LanguageDefinitions.DefaultLanguage }; return PartialView("_ProcessFields", model); }
private bool DoesProcessExist(ProcessTranslation p) { return db.Set<ProcessTranslation>() .Any(t => t.LanguageCode == p.LanguageCode && t.Value == p.Value && t.ProcessId != p.ProcessId); }
public async Task<ActionResult> AddTranslation(ProcessTranslation translation) { if (DoesProcessExist(translation)) { ModelState.AddModelError("Value", ProcessStrings.Validation_AlreadyExists); } 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 k = await db.GetByIdAsync(id); if (k == null) { return HttpNotFound(); } ViewBag.Languages = LanguageDefinitions.GenerateAvailableLanguageDDL(k.Translations.Select(t => t.LanguageCode)); var model = new ProcessTranslation { ProcessId = k.Id }; return View(model); }