Пример #1
0
        public async Task <IStarredTread> ModificationAsync(IStarredTread entity, StarredTreadModification modification, CancellationToken cancellation)
        {
            if (entity == null || modification == null)
            {
                return(null);
            }
            using (var context = await DatabaseStorageService.CreateContextAsync()
                                 .ConfigureAwait(continueOnCapturedContext: false))
            {
                var thread = await context.Set <StarredThread>()
                             .Where(x => x.ThreadKey.Equals(entity.ThreadKey))
                             .FirstOrDefaultAsync(cancellation)
                             .ConfigureAwait(continueOnCapturedContext: false);

                if (thread == null)
                {
                    return(null);
                }

                SetModification(thread, modification);

                await context.SaveChangesAsync(cancellation)
                .ConfigureAwait(continueOnCapturedContext: false);

                return(Represent(thread));
            }
        }
Пример #2
0
 private void SetModification(StarredThread starredThread, StarredTreadModification modification)
 {
     if (modification.NewTimeToMailling != null && starredThread.TimeToMailling != modification.NewTimeToMailling.Value)
     {
         starredThread.TimeToMailling = modification.NewTimeToMailling.Value;
     }
 }
Пример #3
0
        public IStarredTread Modification(IStarredTread entity, StarredTreadModification modification)
        {
            if (entity == null || modification == null)
            {
                return(null);
            }
            using (var context = DatabaseStorageService.CreateContext())
            {
                var thread = context.Set <StarredThread>()
                             .Where(x => x.ThreadKey.Equals(entity.ThreadKey))
                             .FirstOrDefault();

                if (thread == null)
                {
                    return(null);
                }

                SetModification(thread, modification);

                context.SaveChanges();
                return(Represent(thread));
            }
        }