public static IList <Customer> GetCustomer(CustomerFilterVM customerFilter) { using (IDataContext model = new NorhWindModel()) { var customer = CustomerProvider.GetCustomer(model, customerFilter); return(customer); } }
public static List <Order> GetCustomer(string customerId) { using (IDataContext model = new NorhWindModel()) { var orders = OrderProvider.GetOrders(model); return(orders); } }
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); //} }
public static List <Employee> GetEmplyees(NorhWindModel Context) { var query = Context.Employees.ToList(); return(query.Any <Employee>() ? query : null); }