예제 #1
0
        public async Task <Client> CreateClientAsync(UpdateClientRequest client)
        {
            var dbClient = _mapper.Map <ClientDb>(client);

            _clCtx.Clients.Add(dbClient);

            await _clCtx.SaveChangesAsync();

            return(_mapper.Map <Client>(dbClient));
        }
예제 #2
0
        public async Task <Client> CreateClientAsync(ClientRequest clientRequest)
        {
            var dbClient = await _context.Clients.Where(c => (c.Name == clientRequest.Name && c.City == clientRequest.Name)).ToArrayAsync();

            if (dbClient.Length > 0)
            {
                throw new RequestedResourceHasConflictException("city");
            }

            var client = Mapper.Map <ClientRequest, Client>(clientRequest);

            _context.Clients.Add(client);

            await _context.SaveChangesAsync();

            return(client);
        }