public IHttpActionResult PostAutodeskUser(AutodeskUser autodeskUser) { if (!AutodeskUserExists(autodeskUser.username)) { db.AutodeskUsers.Add(autodeskUser); } else { return(Ok(user)); } try { db.SaveChanges(); } catch (DbUpdateException) { if (AutodeskUserExists(autodeskUser.username)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = autodeskUser.username }, autodeskUser)); }
public IHttpActionResult GetAutodeskUser() { string username = ""; string password = ""; var request = Request; var headers = request.Headers; if (headers.Contains("username")) { username = headers.GetValues("username").First(); } if (headers.Contains("task") && headers.GetValues("task").First() == "verifyUsername") { AutodeskUser result = db.AutodeskUsers.FirstOrDefault(x => x.username == username); if (result == null) { return(Ok(false)); } else { return(Ok(true)); } } else { if (headers.Contains("password")) { password = headers.GetValues("password").First(); } AutodeskUser result = db.AutodeskUsers.FirstOrDefault(x => x.username == username && x.userPassword == password); if (result == null) { return(Ok(false)); } else { return(Ok(true)); } } }