public ActionResult Create(CreateModel createModel)
        {
            if (!User.IsInRole("buildingmanager")) { return new HttpUnauthorizedResult(); }

            if (ModelState.IsValid) {
                // TODO provjeri da li vec postoji zgrada sa tom adresom

                LegalPerson legalPerson = personsRepository.GetLegalPersonByUsername(User.Identity.Name);
                var buildingManager = buildingManagersRepository.GetByLegalPerson(legalPerson);

                try {
                    Building building = new Building(buildingManager) {
                        Address =
                            new Address(createModel.Address.StreetAddress, createModel.Address.StreetAddressNumber,
                                        citiesRepository.GetById(createModel.Address.City.Id))
                    };

                    buildingsRepository.SaveOrUpdate(building);

                    return RedirectToAction("index");

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

            }

            createModel.Address.Cities = new SelectList(citiesRepository.GetCitiesWithCadastres(), "Id", "Name",
                                                      createModel.Address.City.Id);
            createModel.Roles = Roles.GetRolesForUser();

            return View(createModel);
        }
        public ActionResult Create()
        {
            if (!User.IsInRole("buildingmanager")) { return new HttpUnauthorizedResult(); }

            AddressModel addressModel = new AddressModel() {
                Cities = new SelectList(citiesRepository.GetCitiesWithCadastres(), "Id", "Name")
            };

            var createModel = new CreateModel() {
                Address = addressModel,
                Roles = Roles.GetRolesForUser()
            };

            return View(createModel);
        }