Exemple #1
0
        public async Task AddAsync(Domain.Neuron neuron)
        {
            var neuronEntity = new Entities.Neuron
            {
                Id          = neuron.Id,
                Information = neuron.Information,
                Groups      = neuron.Groups
                              .Select(g => new Entities.Group {
                    Name = g
                })
                              .ToList(),
                CreatedAt = neuron.CreatedAt
            };


            context.Neurons.Add(neuronEntity);

            await context.SaveChangesAsync();

            var reminders = neuron.Reminders
                            .Select(r => new Entities.Reminder
            {
                Id      = r.Id,
                At      = r.At,
                State   = MapReminderState(r.State),
                Subject = neuronEntity
            });

            context.Reminders.AddRange(reminders);

            await context.SaveChangesAsync();
        }
Exemple #2
0
 private static Entities.Neuron MapNeuronWithIdOnly(Domain.Neuron neuron)
 {
     return(new Entities.Neuron
     {
         Id = neuron.Id
     });
 }
Exemple #3
0
        private static Domain.Neuron MapNeuron(Entities.Neuron dbNeuron)
        {
            var n = new Domain.Neuron(dbNeuron.Information)
            {
                Id        = dbNeuron.Id,
                Groups    = dbNeuron.Groups.Select(g => g.Name).ToList(),
                CreatedAt = dbNeuron.CreatedAt
            };

            n.Reminders = MapReminders(dbNeuron.Reminders, n);

            return(n);
        }
Exemple #4
0
        private static Entities.Neuron MapNeuron(Domain.Neuron neuron)
        {
            var dbNeuron = new Entities.Neuron
            {
                Id          = neuron.Id,
                Information = neuron.Information,
                Groups      = neuron.Groups.Select(g => new Entities.Group
                {
                    Name     = g,
                    NeuronId = neuron.Id
                }).ToList()
            };

            dbNeuron.Reminders = MapReminders(neuron.Reminders, dbNeuron);

            return(dbNeuron);
        }
Exemple #5
0
        private static List <Domain.Reminder> MapReminders(IEnumerable <Entities.Reminder> dbReminders, Domain.Neuron subject)
        {
            var reminders = dbReminders
                            .Select(r => new Domain.Reminder(subject)
            {
                Id    = r.Id,
                At    = r.At,
                State = MapReminderState(r.State)
            })
                            .ToList();

            return(reminders);
        }