Ejemplo n.º 1
0
        public Bill updateLocalitiesSoccerGame(string code_client, DateTime date_bill, string way_pay, List <Locality> localities)
        {
            Bill bill = new Bill();

            try
            {
                DAOService      service  = new DAOService();
                List <Locality> list_loc = localities;
                if (list_loc != null && list_loc.Count >= 0 && code_client != null && !code_client.Equals(""))
                {
                    SoccerGame soccerGame = new SoccerGame()
                    {
                        code_soccergame = list_loc[0].code_soccergame,
                        localities      = list_loc
                    };
                    bill = service.generateBill(soccerGame, date_bill, code_client, way_pay);
                }
                else
                {
                    bill = new Bill();
                }
            }
            catch (Exception e)
            {
                bill = new Bill();
            }
            return(bill);
        }
Ejemplo n.º 2
0
        //Get roles for application
        public static DAplRoles GetApplicationRoles(string userName, string apl)
        {
            DAplRoles AplRoles = new DAplRoles()
            {
                Pravice = DAOService.GetPravice(userName, apl)
            };

            return(AplRoles);
        }
        public override IDataService GetDataService(ApplicationDataServices service)
        {
            switch (service)
            {
            case ApplicationDataServices.DAOService: return(DAOService.GetInstance());

            case ApplicationDataServices.LogService: return(LogService.GetInstance());

            case ApplicationDataServices.RequestService: return(RequestService.GetInstance());

            default: return(null);
            }
        }
Ejemplo n.º 4
0
        public List <SoccerGame> getAvailableSoccerGames()
        {
            List <SoccerGame> list;

            try
            {
                DAOService service = new DAOService();
                list = service.getAvailableSoccerGames();
            } catch (Exception e)
            {
                list = new List <SoccerGame>();
            }
            return(list);
        }
Ejemplo n.º 5
0
        public List <Client> getClients()
        {
            List <Client> list;

            try
            {
                DAOService service = new DAOService();
                list = service.getClients();
            }
            catch (Exception e)
            {
                list = new List <Client>();
            }
            return(list);
        }
Ejemplo n.º 6
0
        public SoccerGame getSoccerGame(string code_soccergame)
        {
            SoccerGame soccerGame;

            try
            {
                DAOService service = new DAOService();
                soccerGame = service.getSoccerGame(code_soccergame);
            }
            catch (Exception e)
            {
                soccerGame = new SoccerGame();
            }
            return(soccerGame);
        }
Ejemplo n.º 7
0
        public List <Bill> getClientBills(string code_client)
        {
            List <Bill> list_bill;

            try
            {
                DAOService service = new DAOService();
                list_bill = service.getClientBills(code_client);
            }
            catch (Exception e)
            {
                list_bill = new List <Bill>();
            }
            return(list_bill);
        }
Ejemplo n.º 8
0
        //check SessionToken is valid
        public static bool IsTokenValid(string sessionToken)
        {
            bool IsValid = false;

            AuthSession authSession = DAOService.GetSession(sessionToken);

            if (authSession.Expired > DateTime.Now)
            {
                IsValid = true;

                //we extend session for another 30min
                authSession.Expired = DateTime.Now.AddSeconds(1800);
                DAOService.ExtendSession(authSession);
            }


            return(IsValid);
        }
Ejemplo n.º 9
0
        //create new SessionToken
        private static string GetNewSessionToken(string userName)
        {
            string SessionAuthToken = Guid.NewGuid().ToString();

            Uporabniki Uporabnik = DAOService.GetUporabnik(userName);

            AuthSession authSession = new AuthSession()
            {
                SessionToken   = SessionAuthToken,
                UporabnikKLJ   = Uporabnik.UporabnikKLJ,
                SessionTimeOut = 1800,
                Issued         = DateTime.Now,
                Expired        = DateTime.Now.AddSeconds(1800)
            };

            DAOService.SaveNewSession(authSession);

            return(SessionAuthToken);
        }
Ejemplo n.º 10
0
        //validate user in Active Directory(AD)
        private static bool ValidateUserOrRIFID(string userNameOrRIFID)
        {
            bool   valid  = false;
            string domain = "novakbm.nkbm.si";

            try
            {
                //we try to check userName in AD
                try
                {
                    using (var domainContext = new PrincipalContext(ContextType.Domain, domain))
                    {
                        using (UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, userNameOrRIFID))
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    //TODO
                }


                //we try to check if RFID is valid
                #pragma warning disable CS0162 // Unreachable code detected
                if (DAOService.GetUporabnik(userNameOrRIFID).RFID == userNameOrRIFID)
                {
                    return(true);
                }
                #pragma warning restore CS0162 // Unreachable code detected
            }
            catch (Exception ex)
            {
                //TODO
            }


            return(valid);
        }