Esempio n. 1
0
        public ValidationResult <List <RolePosition> > GetPosition()
        {
            if (sqlConnect.GetConnect)
            {
                sqlConnect.OpenConn();
            }

            RolePosition rolePosition;



            ValidationResult <List <RolePosition> > result = new ValidationResult <List <RolePosition> >()
            {
                IsValid      = true,
                ResultObject = new List <RolePosition>()
            };

            try
            {
                string commPart = "SELECT DISTINCT \"Position\" FROM maindb.\"Staff\" WHERE \"Position\" != 'Управляющий'";

                NpgsqlCommand    command     = new NpgsqlCommand(commPart, sqlConnect.GetNewSqlConn().GetConn);
                NpgsqlDataReader readerTable = command.ExecuteReader();

                foreach (DbDataRecord dbDataRecord in readerTable)
                {
                    rolePosition = new RolePosition(

                        dbDataRecord["Position"].ToString());
                    result.ResultObject.Add(rolePosition);
                }
                readerTable.Close();
            }
            catch (PostgresException exp)
            {
                result = new ValidationResult <List <RolePosition> >
                {
                    IsValid = false,
                    Errors  = new List <string> {
                        exp.SqlState
                    }
                };
            }

            finally
            {
                if (!sqlConnect.GetConnect)
                {
                    sqlConnect.CloseConn();
                }
            }
            return(result);
        }
 public static Point GetPoint(RolePosition rp)
 {
     return(rolesPoints[(int)rp]);
 }
 public static void SetPoint(RolePosition rp, Point pt)
 {
     rolesPoints[(int)rp] = pt;
 }