public ActionResult Confirm(int id, ConfirmModel confirmModel)
        {
            if (!User.IsInRole("representative")) { return new HttpUnauthorizedResult(); }

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

            Person person = personsRepository.GetPersonByUsername(User.Identity.Name);
            if (person.Oib != maintenance.Representative.Oib) {
                return new HttpUnauthorizedResult();
            }

            if(confirmModel.IsConfirmed == false && string.IsNullOrEmpty(confirmModel.Remark)) {
                ModelState.AddModelError("Remark", "Ukoliko obavljanje posla nije pozitivno potvrđeno, obavezno je potrebno upisati napomene izvođačima radova.");
            }

            if(ModelState.IsValid) {
                if(confirmModel.IsConfirmed) {
                    if(!string.IsNullOrEmpty(confirmModel.Remark)) {
                        maintenance.SetMaitenanceCompleted(confirmModel.Remark);
                    } else {
                        maintenance.SetMaitenanceCompleted();
                    }

                } else {
                    maintenance.SetWorkAsNotDone(confirmModel.Remark);
                }

                var submitterUrl = Url.Action("details", "maintenance", new { Id = maintenance.Id }, "http");
                var contractorUrl = Url.Action("maintenance", "contractor", new {Id = maintenance.Id}, "http");
                emailNotifier.NotifyOfMaintenanceAcception(maintenance, submitterUrl, contractorUrl);
                return RedirectToAction("details", new {Id = maintenance.Id});
            }

            confirmModel.Maintenance = Mapper.Map<Maintenance, MaintenanceDetailModel>(maintenance);
            confirmModel.Roles = Roles.GetRolesForUser();
            confirmModel.CurrentRole = "representative";
            confirmModel.Links = new LinksModel() {
                Id = maintenance.Building.Id,
                Links = NavLinksGenerator.GetRepresentativeLinks(maintenance.Building, "Kvarovi")
            };

            return View(confirmModel);
        }
        public ActionResult Confirm(int id)
        {
            if (!User.IsInRole("representative")) { return new HttpUnauthorizedResult(); }

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

            Person person = personsRepository.GetPersonByUsername(User.Identity.Name);
            if(person.Oib != maintenance.Representative.Oib) {
                return new HttpUnauthorizedResult();
            }

            var model = new ConfirmModel {
                Maintenance = Mapper.Map<Maintenance, MaintenanceDetailModel>(maintenance),
                Roles = Roles.GetRolesForUser(),
                CurrentRole = "representative",
                Links = new LinksModel() { Id = maintenance.Building.Id, Links = NavLinksGenerator.GetRepresentativeLinks(maintenance.Building, "Kvarovi") }
            };

            return View(model);
        }