public ActionResult RegisterManager(RegisterManagerUserModel managerModel)
        {
            if (ModelState.IsValid) {
                Person person = personsRepository.GetByOib(managerModel.Oib);
                bool isUserExistingForPerson = false;
                if(person != null) {
                    var existingUser = housingMgmtUsersRepository.GetUserByPerson(person);
                    isUserExistingForPerson = existingUser != null;
                }

                if (!isUserExistingForPerson) {

                    MembershipCreateStatus createStatus;
                    NHibernateMembershipUser membershipUser =
                        Membership.CreateUser(managerModel.UserName, managerModel.Password, managerModel.Email,
                                              null, null, true, null, out createStatus) as NHibernateMembershipUser;

                    if (createStatus == MembershipCreateStatus.Success) {
                        if (person == null) {
                            City city = citiesRepository.GetById(managerModel.City);
                            person = new LegalPerson(managerModel.Oib, managerModel.Name) {
                                NumberOfBankAccount = managerModel.NumberOfBankAccount,
                                Address = new Address(managerModel.StreetAddress, managerModel.StreetAddressNumber, city)
                            };

                            if (!string.IsNullOrEmpty(managerModel.TelephoneNumber)) {
                                person.AddTelephone(new Telephone("Telefon", managerModel.TelephoneNumber));
                            }

                            if (!string.IsNullOrEmpty(managerModel.MobileNumber)) {
                                person.AddTelephone(new Telephone("Mobitel", managerModel.MobileNumber));
                            }
                        }

                        if (person is LegalPerson) {
                            BuildingManager buildingManager = null;

                            try {
                                membershipUser.User.Person = person;

                                var managerRole = rolesRepository.GetRole("buildingmanager");
                                membershipUser.User.AddRole(managerRole);

                                var partitionSpaces = partitionSpacesRepository.GetPartitionSpaces(person);
                                if (partitionSpaces.Count > 0) {
                                    var ownerRole = rolesRepository.GetRole("owner");
                                    membershipUser.User.AddRole(ownerRole);
                                }

                                LegalPerson legalPerson = (LegalPerson) person;
                                buildingManager = new BuildingManager(legalPerson);

                                FormsAuthentication.SetAuthCookie(managerModel.UserName, false);
                                buildingManagersRepository.SaveOrUpdate(buildingManager);
                                emailNotifier.NotifyOfRegistration(membershipUser.User);
                                return RedirectToAction("index", "dashboard");

                            } catch (BusinessRulesException ex) {
                                ex.CopyTo(ModelState);
                            }
                        } else {
                            ModelState.AddModelError("Oib", "Osoba sa ovim OIB-om je već upisana te nije pravna osoba.");
                        }

                    } else {
                        ModelState.AddModelError("", errorCodeToString(createStatus));
                    }
                } else {
                    ModelState.AddModelError("", "Navedena osoba već ima kreiran korisnički račun.");
                }
            }

            managerModel.Cities = new SelectList(citiesRepository.GetAll(), "Id", "Name", managerModel.City);

            return View(managerModel);
        }
        public ActionResult RegisterManager()
        {
            if (User.Identity.IsAuthenticated) {
                return RedirectToAction("index", "dashboard");
            }

            RegisterManagerUserModel model = new RegisterManagerUserModel {
                Cities = new SelectList(citiesRepository.GetAll(), "Id", "Name")
            };

            return View(model);
        }