Exemplo n.º 1
0
        public async Task <Job> AddAsync(Job job)
        {
            job.Id = Helper.CreateKey();
            var entry = await _db.Jobs.AddAsync(job);

            await _db.SaveChangesAsync();

            return(entry.Entity);
        }
Exemplo n.º 2
0
        public async Task<Folder> AddAsync(string path)
        {
            var folder = new Folder
            {
                Id = Helper.CreateKey(),
                Path = path
            };

            var entry = await _db.Folders.AddAsync(folder);

            await _db.SaveChangesAsync();

            entry.State = EntityState.Detached;

            return folder;
        }
Exemplo n.º 3
0
        public async Task <Item> AddAsync(string collectionName, string data, string userId, DateTimeOffset datetime)
        {
            using (var tran = await _db.Database.BeginTransactionAsync())
            {
                var item = new Item
                {
                    Id             = Helper.CreateKey(),
                    CollectionName = collectionName,
                    CreatedAt      = datetime,
                    UpdatedAt      = datetime,
                    CreatedBy      = userId,
                    UpdatedBy      = userId,
                    IsValid        = true,
                };

                await _db.AddAsync(item);

                await _db.SaveChangesAsync();

                var record = new ItemRecord
                {
                    Id        = Helper.CreateKey(),
                    ItemId    = item.Id,
                    Data      = data,
                    CreatedAt = datetime,
                    CreatedBy = userId,
                };

                item.Data      = data;
                item.CurrentId = record.Id;

                await _db.AddAsync(record);

                await _db.SaveChangesAsync();

                tran.Commit();

                _db.Entry(item).State = EntityState.Detached;

                return(item);
            }
        }
Exemplo n.º 4
0
        public async Task <File> AddAsync(string folderId, string name, string binaryPath, string contentType, long size, string userId, DateTimeOffset datetime)
        {
            var file = new File
            {
                Id             = Helper.CreateKey(),
                FolderId       = folderId,
                Name           = name,
                BinaryPath     = binaryPath,
                ContentType    = contentType,
                Size           = size,
                LastModifiedAt = datetime,
                LastModifiedBy = userId
            };

            await _db.Files.AddAsync(file);

            await _db.SaveChangesAsync();

            _db.Entry(file).State = EntityState.Detached;

            return(file);
        }