Exemplo n.º 1
0
        public async Task UpdateClient(int id, CreateOrUpdateClientRequest request)
        {
            var client = context.Clients.Find(id);

            client.Name           = request.Name;
            client.LastName       = request.LastName;
            client.TrainerId      = request.TrainerId != 0 ? request.TrainerId : null;
            client.SubscriptionId = request.SubscriptionId != 0 ? request.SubscriptionId : null;
            await context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task AddClient(CreateOrUpdateClientRequest request)
        {
            var client = new Client {
                Name           = request.Name,
                LastName       = request.LastName,
                TrainerId      = request.TrainerId != 0 ? request.TrainerId : null,
                SubscriptionId = request.SubscriptionId != 0 ? request.SubscriptionId : null
            };
            await context.Clients.AddAsync(client);

            await context.SaveChangesAsync();
        }