public async Task <ShopLeaseInfo> CreateAsync(ShopLeaseInfo shopLeaseInfo, CancellationToken cancellationToken = default(CancellationToken)) { if (shopLeaseInfo == null) { throw new ArgumentNullException(nameof(shopLeaseInfo)); } Context.Add(shopLeaseInfo); await Context.SaveChangesAsync(cancellationToken); return(shopLeaseInfo); }
public async Task UpdateAsync(ShopLeaseInfo shopLeaseInfo, CancellationToken cancellationToken = default(CancellationToken)) { if (shopLeaseInfo == null) { throw new ArgumentNullException(nameof(shopLeaseInfo)); } Context.Attach(shopLeaseInfo); Context.Update(shopLeaseInfo); try { await Context.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException) { } }
public async Task SaveAsync(SimpleUser user, string buildingId, ShopLeaseInfo shopLeaseInfo, CancellationToken cancellationToken = default(CancellationToken)) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (shopLeaseInfo == null) { throw new ArgumentNullException(nameof(shopLeaseInfo)); } //查看楼盘是否存在 if (!Context.Shops.Any(x => x.Id == shopLeaseInfo.Id)) { Shops shops = new Shops() { Id = shopLeaseInfo.Id, BuildingId = buildingId, CreateUser = user.Id, CreateTime = DateTime.Now, OrganizationId = user.OrganizationId, ExamineStatus = 0 }; Context.Add(shops); } //基本信息 if (!Context.ShopLeaseInfos.Any(x => x.Id == shopLeaseInfo.Id)) { Context.Add(shopLeaseInfo); } else { Context.Attach(shopLeaseInfo); Context.Update(shopLeaseInfo); } try { await Context.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException) { } }