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

                if(!isUserExistingForPerson) {
                    MembershipCreateStatus createStatus;
                    NHibernateMembershipUser membershipUser =
                        Membership.CreateUser(ownerUserModel.UserName, ownerUserModel.Password, ownerUserModel.Email,
                                              null, null, true, null, out createStatus) as NHibernateMembershipUser;

                    if (createStatus == MembershipCreateStatus.Success) {
                        if (person == null) {
                            City city = citiesRepository.GetById(ownerUserModel.Address.City.Id);

                            if (string.IsNullOrEmpty(ownerUserModel.Surname)) {
                                person = new LegalPerson(ownerUserModel.Oib, ownerUserModel.Name);
                            } else {
                                person = new PhysicalPerson(ownerUserModel.Oib, ownerUserModel.Name, ownerUserModel.Surname);
                            }

                            person.Address = new Address(ownerUserModel.Address.StreetAddress, ownerUserModel.Address.StreetAddressNumber,
                                                         city);

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

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

                        try {
                            membershipUser.User.Person = person;

                            var role = rolesRepository.GetRole("owner");
                            membershipUser.User.AddRole(role);

                            FormsAuthentication.SetAuthCookie(ownerUserModel.UserName, false);
                            personsRepository.SaveOrUpdate(person);
                            emailNotifier.NotifyOfRegistration(membershipUser.User);
                            return RedirectToAction("index", "dashboard");

                        } catch (BusinessRulesException ex) {
                            ex.CopyTo(ModelState);
                        }

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

            }

            ownerUserModel.Address.Cities = new SelectList(citiesRepository.GetAll(), "Id", "Name");

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

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

            return View(model);
        }