public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Branches,Language")] BranchesTrans BranchesTrans) { if (id != BranchesTrans.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(BranchesTrans); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BranchesTransExists(BranchesTrans.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["Branches"] = new SelectList(_context.Branches, "Id", "Id", BranchesTrans.Branches); ViewData["Language"] = new SelectList(_context.Languages, "Id", "Code", BranchesTrans.Language); return(View(BranchesTrans)); }
public async Task <IActionResult> Create(int Branches, string currentpath, [Bind("Id,Name,Description,Branches,Language")] BranchesTrans BranchesTrans) { if (ModelState.IsValid) { if (Branches == 0) { Branches branch = new Branches(); _context.Add(branch); BranchesTrans.Branches = branch.Id; } _context.Add(BranchesTrans); await _context.SaveChangesAsync(); String[] url = new String[4]; url = currentpath.Split('/'); return(RedirectToAction("Index", url[2])); } ViewData["Branches"] = new SelectList(_context.Branches, "Id", "Id", BranchesTrans.Branches); ViewData["Language"] = new SelectList(_context.Languages, "Id", "Code", BranchesTrans.Language); return(View(BranchesTrans)); }