public ActionResult Fix(int id, FixModel fixModel)
        {
            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); }

            if(string.IsNullOrEmpty(fixModel.Maintenance.ContractorsConclusion)) {
                ModelState.AddModelError("Maintenance.ContractorsConclusion", "Zaključak izvođača radova ne može biti prazan.");
            }

            if(ModelState.IsValid) {
                maintenance.ContractorsConclusion = fixModel.Maintenance.ContractorsConclusion;
                maintenance.SetWorkAsDone();
                var url = Url.Action("details", "maintenance", new {Id = maintenance.Id}, "http");
                emailNotifier.NotifyOfMaintenanceCompletition(maintenance, url);
                return RedirectToAction("maintenance", new {Id = maintenance.Id});
            }

            fixModel.Roles = Roles.GetRolesForUser();
            fixModel.Maintenance = Mapper.Map<Maintenance, MaintenanceDetailModel>(maintenance);

            return View(fixModel);
        }
        public ActionResult Fix(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) || maintenance.StatusOfMaintenance == StatusOfMaintenance.Completed) {  return new HttpStatusCodeResult(405); }

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

            return View(model);
        }