Beispiel #1
0
        public async Task <IdentityResult> CreateAsync(User user, CancellationToken cancellationToken)
        {
            db.Add(user);

            await db.SaveChangesAsync(cancellationToken);

            return(await Task.FromResult(IdentityResult.Success));
        }
        public static async Task UpdateOutputFormAsync(this TypiconDBContext dbContext, OutputDay outputDay)
        {
            var outputDays = dbContext.Set <OutputDay>()
                             .Where(c => c.TypiconId == outputDay.TypiconId && c.Date.Date == outputDay.Date.Date);

            if (outputDays.Any())
            {
                dbContext.Set <OutputDay>().RemoveRange(outputDays);
            }

            dbContext.Set <OutputDay>().Add(outputDay);

            await dbContext.SaveChangesAsync();
        }
Beispiel #3
0
        public static async Task ClearOutputFormsAsync(this TypiconDBContext dbContext, int typiconId, bool deleteModifiedOutputDays)
        {
            //var query = $"DELETE FROM OUTPUTDAY WHERE TypiconId={typiconId} ";
            //int numberOfRowDeleted = await dbContext.Database.ExecuteSqlRawAsync(query);

            var days = dbContext.Set <OutputDay>().Where(c => c.TypiconId == typiconId);

            //если оставляем измененные вручную выходные фомры
            if (!deleteModifiedOutputDays)
            {
                //выбираем только те, у которых ModifiedDate == null
                //и не существует изменных вручную дочерних служб
                days = days.Where(c => c.ModifiedDate == null)
                       .Where(c => !c.Worships.Any(e => e.ModifiedDate != null));
            }

            //var list = days.ToList();

            dbContext.Set <OutputDay>().RemoveRange(days.ToList());

            await dbContext.SaveChangesAsync();
        }
Beispiel #4
0
        public static async Task AddTypiconVersionAsync(this TypiconDBContext dbContext, TypiconVersion version)
        {
            dbContext.Set <TypiconVersion>().Add(version);

            var iHasIds = dbContext.ChangeTracker.Entries()
                          .Where(c => c.State == EntityState.Added &&
                                 c.IsKeySet &&
                                 c.Entity is ITypiconVersionChild child &&
                                 child.TypiconVersionId == version.Id);

            //.Select(c => c.Entity as ITypiconVersionChild);

            foreach (var entry in iHasIds)
            {
                //entry.
                (entry.Entity as ITypiconVersionChild).Id = default(int);
                //entry.Id = default(int);
            }

            dbContext.Set <TypiconVersion>().Update(version);

            await dbContext.SaveChangesAsync();
        }
Beispiel #5
0
 public Task <int> SaveChangesAsync()
 {
     return(dbContext.SaveChangesAsync());
 }
Beispiel #6
0
        public static async Task RemoveTypiconClaimAsync(this TypiconDBContext dbContext, TypiconClaim claim)
        {
            dbContext.Set <TypiconClaim>().Remove(claim);

            await dbContext.SaveChangesAsync();
        }
Beispiel #7
0
        public static async Task AddTypiconEntityAsync(this TypiconDBContext dbContext, TypiconEntity entity)
        {
            dbContext.Set <TypiconEntity>().Add(entity);

            await dbContext.SaveChangesAsync();
        }
        public static async Task UpdateTypiconEntityAsync(this TypiconDBContext dbContext, TypiconEntity typiconEntity)
        {
            dbContext.Set <TypiconEntity>().Update(typiconEntity);

            await dbContext.SaveChangesAsync();
        }
        public static async Task UpdateTypiconVersionAsync(this TypiconDBContext dbContext, TypiconVersion version)
        {
            dbContext.Set <TypiconVersion>().Update(version);

            await dbContext.SaveChangesAsync();
        }
        public static async Task UpdateModifiedYearAsync(this TypiconDBContext dbContext, ModifiedYear modifiedYear)
        {
            dbContext.Set <ModifiedYear>().Update(modifiedYear);

            await dbContext.SaveChangesAsync();
        }
Beispiel #11
0
        public static async Task AddTypiconVersionErrorAsync(this TypiconDBContext dbContext, IEnumerable <TypiconVersionError> errors)
        {
            await dbContext.Set <TypiconVersionError>().AddRangeAsync(errors);

            await dbContext.SaveChangesAsync();
        }
Beispiel #12
0
        public static async Task AddTypiconVersionErrorAsync(this TypiconDBContext dbContext, TypiconVersionError error)
        {
            await dbContext.Set <TypiconVersionError>().AddAsync(error);

            await dbContext.SaveChangesAsync();
        }