public void Create(ClientVm clientVm) { var client = _passportContext.Set <Client>() .FirstOrDefault(x => x.Code == clientVm.ClientId); _passportContext.Set <ClientScope>() .DeleteMany(x => x.ClientId == client.Id); _passportContext.SaveChanges(); foreach (var scopeName in clientVm.AllowedScopes) { var scope = _passportContext.Set <Scope>() .FirstOrDefault(x => x.Name == scopeName); var clientScope = new ClientScope { ClientId = client.Id, ScopeId = scope.Id }; _passportContext.Set <ClientScope>().Add(clientScope); } _passportContext.SaveChanges(); }
public void CreateClient() { var res = ClientSvc.CreateClient(0, clientName, ClientKeyStatus.Pending); _clientVm = res.Client; _clientKeyVm = res.Key; Assert.IsTrue(res.IsSuccess); }
public void Update(int id, ClientVm clientVm) { var client = _passportContext.Set <Client>().Find(id); client.Name = clientVm.Name; client.GrantTypeId = clientVm.GrantTypeId; _passportContext.SaveChanges(); _clientSecretRepository.Create(clientVm); _clientScopeRepository.Create(clientVm); }
public void Create(ClientVm clientVm) { var client = new Client { Code = clientVm.ClientId, Name = clientVm.Name, GrantTypeId = clientVm.GrantTypeId }; _passportContext.Set <Client>().Add(client); _passportContext.SaveChanges(); _clientSecretRepository.Create(clientVm); _clientScopeRepository.Create(clientVm); }
/*TODO : MAKE SURE THAT ALL THE TRANSACTION ON SET ARE LOGGED IN A TABLE*/ /// <summary> /// Create a new client record. /// </summary> /// <param name="ownerId">Owner Id</param> /// <param name="name">Client Name</param> /// <param name="status">Client Status</param> /// <returns><![CDATA[ (ClientVm Client, ClientKeyVm Key, bool IsSuccess, String Message) ]]></returns> public (ClientVm Client, ClientKeyVm Key, bool IsSuccess, String Message) CreateClient(int ownerId, string name, ClientKeyStatus status) { try { var dbCheck = ClientDataAccess.Client.Find(f => f.OwnerId == ownerId && f.Name.ToLower() == name.ToLower()); if (dbCheck != null) { return(null, null, false, ResourceManagerMessages.Error.CLIENT_ADD_ALREADY_EXISTS); } // Create the Client Resource var dbView = (new ClientVm() { Name = name }).ToEntityCreate(ownerId); dbView = ClientDataAccess.Client.Create(dbView); // Generate a new Client Key var dbKey = (new ClientKeyVm() { Status = status }).ToEntityCreate(dbView.Id); dbKey = ClientDataAccess.ClientKey.Create(dbKey); ClientDataAccess.Save(); var client = new ClientVm(dbView); var key = new ClientKeyVm(dbKey); return(client, key, true, ResourceManagerMessages.Success.CLAIM_CREATED); } catch (DbEntityValidationException ex) { #if (DEBUG) // for debuging entity framework foreach (var error in ex.EntityValidationErrors.SelectMany(valError => valError.ValidationErrors)) { Console.WriteLine(error.ErrorMessage); } #endif throw; } catch { throw; } }
// GET: Admin public ActionResult Index() { using (CarInsuranceEntities db = new CarInsuranceEntities()) { var allClients = (from c in db.Clients select c).ToList(); var viewClients = new List <ClientVm>(); foreach (var client in allClients) { var viewClient = new ClientVm(); viewClient.Id = client.Id; viewClient.FirstName = client.FirstName; viewClient.LastName = client.LastName; viewClient.EmailAddress = client.EmailAddress; viewClient.Quote = client.Quote; viewClients.Add(viewClient); } return(View(viewClients)); } }
public void Create(ClientVm clientVm) { var client = _passportContext.Set <Client>() .FirstOrDefault(x => x.Code == clientVm.ClientId); _passportContext.Set <ClientSecret>() .DeleteMany(x => x.ClientId == client.Id); _passportContext.SaveChanges(); var hashedSecret = _cryptoRepository.Hash(clientVm.Secret); var clientSecret = new ClientSecret { ClientId = client.Id, Secret = hashedSecret }; _passportContext.Set <ClientSecret>().Add(clientSecret); _passportContext.SaveChanges(); }
public void Update(int id, ClientVm clientVm) { throw new NotImplementedException(); }
public void Create(ClientVm clientVm) { throw new NotImplementedException(); }
public IActionResult Create([FromBody] ClientVm clientVm) { _clientRepository.Create(clientVm); return(Ok()); }
public IActionResult CreateClient([FromBody] ClientVm dto) { return(Ok(_accountManager.GetListClient())); }