public async Task SaveAsync(EmailTemplate template)
        {
            var dbTemplate = await FindByNameAsync(template.TemplateName);

            using var trans = await db.Database.BeginTransactionAsync();

            if (dbTemplate != null)
            {
                template.Id = dbTemplate.Id;
                db.EmailTemplates.Remove(dbTemplate);
                await db.SaveChangesAsync();
            }
            else
            {
                template.Id = Guid.NewGuid().ToString();
            }
            await db.EmailTemplates.AddAsync(template);

            await db.SaveChangesAsync();

            await trans.CommitAsync();
        }
Beispiel #2
0
        public async Task AddAsync(AppointmentAggregate appointmentAggregate)
        {
            using var trans = await db.Database.BeginTransactionAsync();

            await db.Slots.AddAsync(appointmentAggregate.Slot);

            await db.Appointments.AddRangeAsync(appointmentAggregate.Appointments);

            await db.SaveChangesAsync();

            await trans.CommitAsync();
        }
        public async Task SaveConfigAsync <T>(T config) where T : new()
        {
            var configuration = db.Configurations.Where(c => c.Name == typeof(T).FullName).FirstOrDefault();

            using var tran = await db.Database.BeginTransactionAsync();

            if (configuration != null)
            {
                configuration.Set(config);
                db.Configurations.Update(configuration);
            }
            else
            {
                await db.Configurations.AddAsync(Configuration.From(config));
            }
            await db.SaveChangesAsync();

            await tran.CommitAsync();
        }
Beispiel #4
0
        public async Task AddAsync(User user)
        {
            await db.Users.AddAsync(user);

            await db.SaveChangesAsync();
        }