public IHttpActionResult GetKullaniciById(Kullanicilar kullanici) { KullanicilarDAL kullanicilarDAL = new KullanicilarDAL(); Kullanicilar kullanicilar = kullanicilarDAL.getKullaniciById(kullanici); if (kullanicilar == null) { return(NotFound()); } return(Ok(kullanicilar)); }
protected override System.Threading.Tasks.Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { var apiKey = request.Headers.GetValues("apiKey").FirstOrDefault(); KullanicilarDAL userDAL = new KullanicilarDAL(); var user = userDAL.GetUserByApiKey(apiKey); if (user != null) { var principal = new ClaimsPrincipal(new GenericIdentity(user.UserName, "APIkey")); HttpContext.Current.User = principal; } return(base.SendAsync(request, cancellationToken)); }
public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext) { var actionRoles = Roles; var userName = HttpContext.Current.User.Identity.Name; KullanicilarDAL userDAL = new KullanicilarDAL(); var user = userDAL.GetUserByName(userName); if (user != null && actionRoles.Contains(user.UserRole)) { } else { actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Unauthorized); } }
public IHttpActionResult KullaniciEkle(Kullanicilar kullanicilar) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } KullanicilarDAL kullanicilarDAL = new KullanicilarDAL(); if (kullanicilarDAL.KullaniciEkle(kullanicilar)) { return(Ok()); } { return(InternalServerError()); } }
public IQueryable <Kullanicilar> GetButunKullanicilar() { KullanicilarDAL kullanicilarDAL = new KullanicilarDAL(); return(kullanicilarDAL.GetButunKullanicilar()); }