public IHttpActionResult GetProject(int id) { Title _object = manager.Find(x => x.ID == id); if (_object != null) { return(Ok(_object)); } return(NotFound()); }
public IHttpActionResult PostLogin([FromBody] Login login) { TitleManager titleManager = new TitleManager(); DepartmantManager departmantManager = new DepartmantManager(); ProjectManager projectManager = new ProjectManager(); ProcessManager processManager = new ProcessManager(); ContentManager contentManager = new ContentManager(); CustomerManager customerManager = new CustomerManager(); Employee employee = employeeManager.Find(e => e.email == login.email && e.password == login.password); if (employee != null) { Title title = titleManager.Find(x => x.ID == employee.TitleID); employee.Title = title; Departmant departmant = departmantManager.Find(x => x.ID == employee.DepartmantID); employee.Departmant = departmant; List <Process> processes = processManager.List(x => x.EmployeeID == employee.ID); foreach (Process item in processes) { Project project = projectManager.Find(x => x.ID == item.ProjectID); Customer customer = customerManager.Find(c => c.ID == project.CustomerID); project.Customer = customer; item.Project = project; List <Content> contents = contentManager.List(x => x.ProcessID == item.ID); item.Contents = contents; } employee.Processes = processes; return(Ok(employee)); } return(NotFound()); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { EmployeeManager employeeManager = new EmployeeManager(); CustomerManager customerManager = new CustomerManager(); Employee employee = employeeManager.Find(x => x.email == context.UserName && x.password == context.Password); Customer customer = customerManager.Find(x => x.email == context.UserName && x.password == context.Password); if (employee != null) { if (employee.isActive == false) { context.SetError("Oturum Hatası", "Kullanıcı Pasif"); } else { TitleManager titleManager = new TitleManager(); Title title = titleManager.Find(x => x.ID == employee.TitleID); var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", employee.email)); identity.AddClaim(new Claim("role", "calisan")); identity.AddClaim(new Claim("clientId", employee.ID.ToString())); context.Validated(identity); } } else if (customer != null) { var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", customer.email)); identity.AddClaim(new Claim("role", "musteri")); identity.AddClaim(new Claim("clientId", customer.ID.ToString())); context.Validated(identity); } else { context.SetError("Oturum Hatası", "Kullanıcı adı sifre hatalı"); } }