Exemplo n.º 1
0
        public static bool LoginUser(string username, string password)
        {
            ClientLoginDto clog = new ClientLoginDto {
                KIme_Mail = username, Sifra = password
            };

            try
            {
                SesijaDto sesija = Api.LoginUser(clog);
                MSettings.CurrentSession = new Session()
                {
                    SessionID = sesija.IdSesije
                };

                KorisnikFullDto korisnik = Api.GetUserFullInfo(sesija.IdKorisnika);
                if (korisnik.IdTipaNaloga == (int)User.UserAccountType.Student)
                {
                    MUtility.ShowError("Prijavljivanje sa studentskog naloga je onemoguceno na ovoj aplikaciji!");
                    Api.LogoutUser(MSettings.CurrentSession.SessionID);
                    return(false);
                }
                MSettings.CurrentSession.LoggedUser = MUtility.GenerateUserFromDTO(korisnik);
                return(true);
            }
            catch (Exception ex)
            {
                MSettings.CurrentSession = null;
                MUtility.ShowException(ex);
                return(false);
            }
        }
Exemplo n.º 2
0
 public static void LoadUserCard(int cardId)
 {
     try
     {
         KorisnikFullDto korisnik = Api.GetUserFullInfo(cardId);
         if (korisnik.IdTipaNaloga != (int)User.UserAccountType.Student)
         {
             throw new Exception("Nalog nije studentski");
         }
         LoadedCardUser = MUtility.GenerateUserFromDTO(korisnik);
         KorisnikStanjeDto stanje = Api.UserMealsCount(LoadedCardUser.UserID);
         LoadedCardUser.BreakfastCount = stanje.BrojDorucka;
         LoadedCardUser.LunchCount     = stanje.BrojRuckova;
         LoadedCardUser.DinnerCount    = stanje.BrojVecera;
     }
     catch (Exception ex)
     {
         MUtility.ShowException(ex);
     }
 }