protected virtual bool AssertEmpty(Table table, Row row, string columnName,
                                           string expected, object actual)
        {
            if (Strings.IsEmpty(expected))
            {
                if (actual == null)
                {
                    return(true);
                }
                if (actual is string && Strings.IsEmpty((string)actual))
                {
                    return(true);
                }
                Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, "", actual, GetType(actual));
            }

            if (NULL.Equals(expected))
            {
                if (actual != null)
                {
                    Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, NULL, actual, GetType(actual));
                }
                return(true);
            }

            if (EMPTY.Equals(expected))
            {
                if (actual == null || !(actual is string) || ((string)actual).Length > 0)
                {
                    Assertie.Fail("M_Fixture_Temp_ObjectValidator_AssertEquals", table, row, columnName, EMPTY, ToStringInternal(actual), GetType(actual));
                }
                return(true);
            }
            return(false);
        }
        public static ActionResult <List <OrderModel> > Execute(Guid webSessionId, string connectionString)
        {
            try
            {
                using (var connection = new SqlConnection(connectionString))
                {
                    // create command object
                    var command = new SqlCommand();
                    command.Connection = connection;
                    command.Connection.Open();

                    // authenticate web session
                    if (!WebSessionCheck.Check(webSessionId, connection, command))
                    {
                        return(new UnauthorizedResult());
                    }

                    // select user associated with given web session id
                    command.CommandText = @$ "
                        SELECT users.id
                          FROM users
                          JOIN web_sessions
                            ON users.id = web_sessions.user_id
                         WHERE web_sessions.id = '{webSessionId}'
                           AND web_sessions.expired IS NULL
                    ";
                    var reader = command.ExecuteReader();

                    // if no rows returned, user was not found
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return(new BadRequestResult());
                    }

                    // read returned row to get user id
                    reader.Read();
                    var userId = reader["id"].ToString();
                    reader.Close();

                    // select all active orders for selected user
                    command.CommandText = @$ "
                        SELECT orders.*
                          FROM orders
                         WHERE orders.user_id = '{userId}'
                           AND orders.completed IS NULL
                    ";
                    reader = command.ExecuteReader();

                    // read returned rows to get active orders
                    var activeOrders = new List <OrderModel>();
                    while (reader.Read())
                    {
                        activeOrders.Add(new OrderModel(reader));
                    }
                    reader.Close();

                    return(new OkObjectResult(activeOrders));
                }
        private object ToObject(Type type, Type componentType, string textValue)
        {
            if (textValue == null || NULL.Equals(textValue))
            {
                return(null);
            }

            if (EMPTY.Equals(textValue))
            {
                return("");
            }

            if (type.IsArray)
            {
                if (HasArraySeparator(textValue) || !Section.HasTable(textValue))
                {
                    return(ToArray(componentType, textValue));
                }
                else
                {
                    return(InvokeMethod(componentType, textValue, "GetArray"));
                }
            }
            else if (typeof(IList).IsAssignableFrom(type))
            {
                if (HasArraySeparator(textValue) || !Section.HasTable(textValue))
                {
                    return(ToList(type, componentType, textValue));
                }
                else
                {
                    IList      list   = (IList)type.GetConstructor(EmptyTypes).Invoke(EmptyObjects);
                    MethodInfo method = parent.GetType().GetMethod("AddTo");
                    method.MakeGenericMethod(componentType).Invoke(parent, new object[] { list, textValue });
                    return(list);
                }
            }
            else if (TypeConverter.IsConvertible(type))
            {
                return(TypeConverter.ChangeType(textValue, type));
            }
            else if (typeof(object).Equals(type))
            {
                return(textValue);
            }
            else
            {
                return(InvokeMethod(type, new string[] { textValue }, "GetObject"));
            }
        }
示例#4
0
 protected override void Visit_NULL(NULL node)
 {
     /* MOVE CODE HERE */
 }
示例#5
0
 protected virtual void Visit_NULL(NULL node)
 {
 }
示例#6
0
 srand((unsigned)time(NULL));
 ::MessageBoxW(NULL, lpszMessage, L"Message", 0);