Esempio n. 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();
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private static List <Entities.Reminder> MapReminders(IEnumerable <Domain.Reminder> reminders, Entities.Neuron subject)
        {
            var dbReminders = reminders
                              .Select(r => new Entities.Reminder
            {
                Id      = r.Id,
                Subject = subject,
                At      = r.At,
                State   = MapReminderState(r.State)
            })
                              .ToList();

            return(dbReminders);
        }