public int GuzvaZaUplatu([FromUri] int id, [FromUri] string sid) { try { SesijeProvajder.OtvoriSesiju(); if (!ProvajderPodatakaKorisnika.SesijaValidna(sid)) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("Sesija istekla") }); } if (!ValidatorPrivilegija.KorisnikImaPrivilegiju(sid, ValidatorPrivilegija.UserPrivilegies.CitanjeGuzvaMenza)) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden) { Content = new StringContent("Nemate privilegiju") }); } Menza m = null; m = ProvajderPodatakaMenzi.VratiMenzu(id); if (m == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("Menza nije pronadjena") }); } int procenatGuzveZaUplatu = Convert.ToInt32(ProvajderPodatakaMenzi.BrojObrokaUplacenihUPoslednjihPetMinuta(id) * 0.1); if (procenatGuzveZaUplatu > 100) { procenatGuzveZaUplatu = 100; } return(procenatGuzveZaUplatu); } catch (Exception e) { if (e is HttpResponseException) { throw e; } DnevnikIzuzetaka.Zabelezi(e); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("InternalError: " + e.Message) }); } finally { SesijeProvajder.ZatvoriSesiju(); } }