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(); }
private static Entities.Neuron MapNeuronWithIdOnly(Domain.Neuron neuron) { return(new Entities.Neuron { Id = neuron.Id }); }
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); }
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); }
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); }