public ActionResult Details(int id)
        {
            var maintenance = maintenancesRepository.GetById(id);

            LinksModel links = new LinksModel();
            if (Session["lastPageId"] != null) {
                links.Id = (int)Session["lastPageId"];
            }

            string role = (string)Session["role"] ?? string.Empty;
            if (role == "representative") {
                links.Links = NavLinksGenerator.GetRepresentativeLinks(maintenance.Building, "Kvarovi");
            } else if (role == "buildingmanager") {
                links.Links = NavLinksGenerator.GetManagerLinks(maintenance.Building, "Kvarovi");
            } else if (role == "owner") {
                links.Links = NavLinksGenerator.GetOwnerLinks(maintenance.Building, "Kvarovi");
            }

            var model = new DetailsModel() {
                Maintenance = Mapper.Map<Maintenance, MaintenanceDetailModel>(maintenance),
                Roles = Roles.GetRolesForUser(),
                Links = links,
                CurrentRole = role
            };

            return View(model);
        }
        public ActionResult Maintenance(int id)
        {
            if (!User.IsInRole("contractor")) { return new HttpUnauthorizedResult(); }

            var maintenance = maintenancesRepository.GetById(id);
            if (maintenance == null) { return HttpNotFound(); }

            var legalPerson = personsRepository.GetLegalPersonByUsername(User.Identity.Name);
            if(maintenance.Contractor.Oib != legalPerson.Oib) { return new HttpStatusCodeResult(405); }

            var model = new DetailsModel() {
                Maintenance = Mapper.Map<Maintenance, MaintenanceDetailModel>(maintenance),
                Roles = Roles.GetRolesForUser(),
                CurrentRole = "contractor"
            };

            return View("~/Views/Maintenance/Details.cshtml" ,model);
        }