예제 #1
0
        public static IList <Customer> GetCustomer(CustomerFilterVM customerFilter)
        {
            using (IDataContext model = new NorhWindModel())
            {
                var customer = CustomerProvider.GetCustomer(model, customerFilter);

                return(customer);
            }
        }
예제 #2
0
        public static List <Order> GetCustomer(string customerId)
        {
            using (IDataContext model = new NorhWindModel())
            {
                var orders = OrderProvider.GetOrders(model);

                return(orders);
            }
        }
예제 #3
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            HttpRequestMessage        request       = actionContext.Request;
            AuthenticationHeaderValue Authorization = request.Headers.Authorization;

            if (Authorization == null)
            {
                actionContext.Response = new AutehnticationFailureResult("Missing Credentials", request).ExecuteResult();
                return;
            }

            if (Authorization.Scheme != "Basic")
            {
                actionContext.Response = new AutehnticationFailureResult("Missing Schema", request).ExecuteResult();
                return;
            }


            if (string.IsNullOrEmpty(Authorization.Parameter))
            {
                actionContext.Response = new AutehnticationFailureResult("Missing Credentials", request).ExecuteResult();
            }

            Tuple <string, string> usrNameAndPwd = ExtractUserAndPassword(Authorization.Parameter);

            if (usrNameAndPwd == null)
            {
                actionContext.Response = new AutehnticationFailureResult("Invalid Credentials", request).ExecuteResult();
            }

            using (var model = new NorhWindModel())
            {
                var user = UserProvider.IsAuthenticated(model, usrNameAndPwd.Item1, usrNameAndPwd.Item2);
                if (!user)
                {
                    actionContext.Response = new AutehnticationFailureResult("User Id or Password  Invalid", request).ExecuteResult();
                }
                Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(usrNameAndPwd.Item1), null);
            }

            //if (actionContext.Request.RequestUri.Scheme != Uri.UriSchemeHttps)
            //{
            //    actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.NotFound);
            //    actionContext.Response.Content = new StringContent("<p>Use HTTPS instead of HTTP.");
            //    UriBuilder uribuilder = new UriBuilder(actionContext.Request.RequestUri);
            //    uribuilder.Scheme = Uri.UriSchemeHttps;
            //    uribuilder.Port = 44306;

            //    actionContext.Response.Headers.Location = uribuilder.Uri;
            //}
            //else
            //{
            //    base.OnAuthorization(actionContext);
            //}
        }
예제 #4
0
        public static List <Employee> GetEmplyees(NorhWindModel Context)
        {
            var query = Context.Employees.ToList();

            return(query.Any <Employee>() ? query : null);
        }