public ActionResult <CapturedTicketCredential> CreateTicketCredential([FromBody] CapturedTicketCredential ticketCredential) { _context.Credentials.Add(ticketCredential); _context.SaveChanges(); return(CreatedAtRoute(nameof(GetTicketCredential), new { id = ticketCredential.Id }, ticketCredential)); }
private bool ContextContainsCredentials(CapturedCredential cred) { switch (cred.Type) { case CapturedCredential.CredentialType.Password: CapturedPasswordCredential passcred = (CapturedPasswordCredential)cred; return(_context.Credentials.Where(C => C.Type == CapturedCredential.CredentialType.Password) .Select(C => (CapturedPasswordCredential)C) .FirstOrDefault(PC => PC.Type == passcred.Type && PC.Domain == passcred.Domain && PC.Username == passcred.Username && PC.Password == passcred.Password ) != null); case CapturedCredential.CredentialType.Hash: CapturedHashCredential hashcred = (CapturedHashCredential)cred; return(_context.Credentials.Where(C => C.Type == CapturedCredential.CredentialType.Hash) .Select(C => (CapturedHashCredential)C) .FirstOrDefault(PC => PC.Type == hashcred.Type && PC.Domain == hashcred.Domain && PC.Username == hashcred.Username && PC.Hash == hashcred.Hash && PC.HashCredentialType == hashcred.HashCredentialType ) != null); case CapturedCredential.CredentialType.Ticket: CapturedTicketCredential ticketcred = (CapturedTicketCredential)cred; return(_context.Credentials.Where(C => C.Type == CapturedCredential.CredentialType.Ticket) .Select(C => (CapturedTicketCredential)C) .FirstOrDefault(PC => PC.Type == ticketcred.Type && PC.Domain == ticketcred.Domain && PC.Username == ticketcred.Username && PC.Ticket == ticketcred.Ticket && PC.TicketCredentialType == ticketcred.TicketCredentialType ) != null); default: return(_context.Credentials.FirstOrDefault(P => P.Type == cred.Type && P.Domain == cred.Domain && P.Username == cred.Username ) != null); } }
public ActionResult <CapturedTicketCredential> EditTicketCredential([FromBody] CapturedTicketCredential ticketCredential) { CapturedTicketCredential matching_ticketCredential = (CapturedTicketCredential)_context.Credentials.FirstOrDefault(c => c.Type == CapturedCredential.CredentialType.Password && ticketCredential.Id == c.Id ); if (matching_ticketCredential == null) { return(NotFound($"NotFound - CapturedTicketCredential with id: {ticketCredential.Id}")); } matching_ticketCredential.Username = ticketCredential.Username; matching_ticketCredential.Ticket = ticketCredential.Ticket; matching_ticketCredential.TicketCredentialType = ticketCredential.TicketCredentialType; matching_ticketCredential.Type = ticketCredential.Type; _context.Credentials.Update(matching_ticketCredential); _context.SaveChanges(); return(matching_ticketCredential); }
public async Task <ActionResult <CapturedTicketCredential> > CreateTicketCredential([FromBody] CapturedTicketCredential credential) { try { CapturedTicketCredential addedCredential = await _service.CreateTicketCredential(credential); return(CreatedAtRoute(nameof(GetHashCredential), new { id = addedCredential.Id }, addedCredential)); } catch (ControllerNotFoundException e) { return(NotFound(e.Message)); } catch (ControllerBadRequestException e) { return(BadRequest(e.Message)); } catch (ControllerUnauthorizedException) { return(new UnauthorizedResult()); } }
public Task <CapturedTicketCredential> EditTicketCredential(CapturedTicketCredential credential) { return(_connection.InvokeAsync <CapturedTicketCredential>("EditTicketCredential", credential)); }
public async Task <ActionResult <CapturedTicketCredential> > EditTicketCredential([FromBody] CapturedTicketCredential credential) { try { return(await _service.EditTicketCredential(credential)); } catch (ControllerNotFoundException e) { return(NotFound(e.Message)); } catch (ControllerBadRequestException e) { return(BadRequest(e.Message)); } catch (ControllerUnauthorizedException) { return(new UnauthorizedResult()); } }
public async Task <IActionResult> CreateTicketCredential(CapturedTicketCredential credential) { CapturedCredential createdCredential = await _context.CreateTicketCredential(credential); return(RedirectToAction("Index", "Data")); }