public IActionResult Branches([FromForm] string id, [FromForm] string name, [FromForm] string abbrname) { if (ModelState.IsValid) { if (id.IsEmpty()) { var branch = new Branch { Name = name, AbbrName = abbrname }; _branchStore.AddIfNotExists(branch, p => p.Name == name); } else { var branch = _branchStore.GetById(int.Parse(id)); if (name.IsNotEmpty() && name != branch.Name) { branch.Name = name; } if (abbrname.IsNotEmpty() && abbrname != branch.AbbrName) { branch.AbbrName = abbrname; } } _branchStore.Accessor.SaveChanges(); } return(RedirectToAction(nameof(Branches))); }