// GET: Branch/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Filiale filiale = m_branchRepository.GetBranch(id.Value);

            if (filiale == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FK_Verband = new SelectList(m_federations, "VerbandKeyGUID", "Name", filiale.FK_Verband);
            return(View(filiale));
        }
        private void SaveBranch(IPropertyBranch branch)
        {
            using (DatabaseContext context = CreateDatabaseContext())
            {
                BranchRepository branchRepository = new BranchRepository(context);
                TBranch          existingBranch   = branchRepository.GetBranch(branch.BranchId, branch.Type);

                if (existingBranch == null)
                {
                    existingBranch = context.Branch.Add(new TBranch
                    {
                        BranchId  = branch.BranchId,
                        Name      = branch.Name,
                        Reference = branch.Reference,
                        Type      = branch.Type
                    });
                }
                else
                {
                    existingBranch.Name      = branch.Name;
                    existingBranch.Reference = branch.Reference;
                }

                context.SaveChanges();

                // set the branchGuid back to the calling branch
                branch.BranchGuid = existingBranch.BranchGuid;
            }
        }