public async Task SaveAsync(SimpleUser user, string buildingId, List <BuildingNoticeFileScope> buildingNoticeFileScopeList, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (buildingNoticeFileScopeList == null || buildingNoticeFileScopeList.Count == 0)
            {
                return;
            }

            foreach (BuildingNoticeFileScope file in buildingNoticeFileScopeList)
            {
                if (String.IsNullOrEmpty(file.FileGuid))
                {
                    file.FileGuid = Guid.NewGuid().ToString("N").ToLower();
                }
                //查看商铺是否存在
                if (!Context.Shops.Any(x => x.Id == file.BuildingNoticeId))
                {
                    BuildingNotice shops = new BuildingNotice()
                    {
                        Id = file.BuildingNoticeId,
                        //BuildingId = buildingId,
                        UserId         = user.Id,
                        CreateTime     = DateTime.Now,
                        OrganizationId = user.OrganizationId,
                        IsDeleted      = false
                    };
                    Context.Add(shops);
                }
                //基本信息
                if (!Context.BuildingNoticeFileScopes.Any(x => x.FileGuid == file.FileGuid))
                {
                    file.CreateTime = DateTime.Now;
                    file.CreateUser = user.Id;
                    Context.Add(file);
                }
                else
                {
                    Context.Attach(file);
                    Context.Update(file);
                }
            }
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
 public async Task UpdateAsync(BuildingNotice buildingNotice, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (buildingNotice == null)
     {
         throw new ArgumentNullException(nameof(buildingNotice));
     }
     Context.Attach(buildingNotice);
     Context.Update(buildingNotice);
     try
     {
         await Context.SaveChangesAsync(cancellationToken);
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
 }
 public async Task <BuildingNotice> CreateAsync(BuildingNotice buildingNotice, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (buildingNotice == null)
     {
         throw new ArgumentNullException(nameof(UpdateRecord));
     }
     Context.Add(buildingNotice);
     try
     {
         await Context.SaveChangesAsync(cancellationToken);
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
     return(buildingNotice);
 }