Exemplo n.º 1
0
 public static Faculty Faculty_From_FakultetFullDto(FakultetFullDto f)
 {
     return(new Faculty()
     {
         FacultyID = f.IdFakultet, Name = f.Naziv
     });
 }
Exemplo n.º 2
0
        public FakultetFullDto VratiFakultetFull([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.CitanjeFakultet))
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)
                    {
                        Content = new StringContent("Nemate privilegiju")
                    });
                }

                Fakultet        f        = null;
                FakultetFullDto fakultet = new FakultetFullDto();

                f = ProvajderPodatakaFakulteta.VratiFakultet(id);
                if (f == null)
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)
                    {
                        Content = new StringContent("Fakultet nije pronadjen")
                    });
                }

                fakultet.IdFakultet = f.IdFakultet;
                fakultet.Naziv      = f.Naziv;
                return(fakultet);
            }
            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();
            }
        }
Exemplo n.º 3
0
        public IHttpActionResult UpdateFakultet([FromBody] FakultetFullDto fdto, [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.ModifikacijaFakultet))
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)
                    {
                        Content = new StringContent("Nemate privilegiju")
                    });
                }

                Fakultet f = ProvajderPodatakaFakulteta.VratiFakultet(fdto.IdFakultet);

                if (f == null)
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)
                    {
                        Content = new StringContent("Fakultet za modifikaciju nije pronadjen")
                    });
                }


                f.Naziv = fdto.Naziv;
                ProvajderPodatakaFakulteta.UpdateFakultet(f);
                return(Ok("Fakutet uspesno modifikovan"));
            }
            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();
            }
        }
Exemplo n.º 4
0
        public static void UpdateFaculty(FakultetFullDto fax)
        {
            RestRequest request = new RestRequest(Method.PUT);

            request.Resource = "fakulteti/update";
            request.AddObject(fax);

            var response = Execute(request);

            if (!(response.HttpStatusCode == HttpStatusCode.OK || response.HttpStatusCode == HttpStatusCode.Redirect))
            {
                throw new Exception("UpdateFacultyError" + "\nServerResponse: " + response.ErrorResponse + "\nHttpStatus: " + response.HttpStatusCode);
            }
        }
Exemplo n.º 5
0
        public IHttpActionResult DodajFakultet([FromBody] FakultetFullDto fdto, [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.DodavanjeFakultet))
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)
                    {
                        Content = new StringContent("Nemate privilegiju")
                    });
                }

                Fakultet f = new Fakultet()
                {
                    Naziv = fdto.Naziv
                };

                ProvajderPodatakaFakulteta.DodajFakultet(f);
                return(Ok("Fakutet uspesno dodat"));
            }
            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)
                });
                //throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("Fakultet nije napravljen!") });
            }
            finally
            {
                SesijeProvajder.ZatvoriSesiju();
            }
        }
Exemplo n.º 6
0
        public static bool UpdateFaculty(Faculty f)
        {
            try
            {
                FakultetFullDto fdto = new FakultetFullDto();
                fdto.IdFakultet = f.FacultyID;
                fdto.Naziv      = f.Name;

                Api.UpdateFaculty(fdto);
                Faculty.UpdateFacultyList();
                return(true);
            }
            catch (Exception e)
            {
                MUtility.ShowException(e);
                return(false);
            }
        }
Exemplo n.º 7
0
        private void NapuniLabele()
        {
            //ime i prezime
            view.FindViewById <TextView>(Resource.Id.profilTextImeIPrezime).Text =
                MSettings.CurrentSession.LoggedUser.FirstName + " " + MSettings.CurrentSession.LoggedUser.LastName;

            FakultetFullDto fax = Api.Api.GetFacultyInfo(MSettings.CurrentSession.LoggedUser.IdFakulteta);

            //univezitet
            view.FindViewById <TextView>(Resource.Id.profilTextFakultet).Text = fax.Naziv;

            //broj idexa
            view.FindViewById <TextView>(Resource.Id.profilTextBrIndexa).Text =
                MSettings.CurrentSession.LoggedUser.BrojIdexa;

            //obroci
            NapuniLabeleSaObrocima();
        }
Exemplo n.º 8
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            view = convertView;

            if (view == null)
            {
                view = Context.LayoutInflater.Inflate(Resource.Layout.profilItem, parent, false);
            }

            korisnik = this[position];
            view.FindViewById <TextView>(Resource.Id.profilItemIme).Text      = korisnik.Ime + " " + korisnik.Prezime;
            view.FindViewById <TextView>(Resource.Id.profilItemUsername).Text = "@" + korisnik.KorisnickoIme;

            dugme = view.FindViewById <Button>(Resource.Id.zapratiDugme);
            if (dugme.Text.Equals("Zaprati"))
            {
                dugme.Click += ZapratiClick;
            }
            else
            {
                dugme.Click += OtpratiClick;
            }

            try
            {
                FakultetFullDto fax = Api.Api.GetFacultyInfo(korisnik.IdFakulteta.Value);
                view.FindViewById <TextView>(Resource.Id.profilItemFax).Text = fax.Naziv;

                return(view);
            }
            catch (Exception ex)
            {
                view.FindViewById <TextView>(Resource.Id.profilItemFax).Text = "Fakultet nije pronadjen";

                return(view);
            }
        }
Exemplo n.º 9
0
        public static bool AddFaculty(Faculty f)
        {
            try
            {
                if (Faculty.Faculties.Exists(x => x.Name == f.Name))
                {
                    MUtility.ShowError("Fakultet sa tim nazivom vec postoji");
                    return(false);
                }

                FakultetFullDto fdto = new FakultetFullDto();
                fdto.Naziv = f.Name;


                Api.AddNewFaculty(fdto);
                Faculty.UpdateFacultyList();
                return(true);
            }
            catch (Exception ex)
            {
                MUtility.ShowException(ex);
                return(false);
            }
        }