Changeset 7d80751 for FarmatikoData/FarmatikoRepo
- Timestamp:
- 01/26/21 13:55:15 (4 years ago)
- Branches:
- master
- Children:
- 7520f88
- Parents:
- db484c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoRepo/Repository.cs
rdb484c9 r7d80751 145 145 public async Task AddPharmacyHead(PharmacyHead pharmacyHead) 146 146 { 147 await _context.PharmacyHeads.AddAsync(pharmacyHead); 148 _context.SaveChanges(); 147 pharmacyHead.Id = 0; 148 if (pharmacyHead.Id == 0) 149 { 150 var pheads = await _context.PharmacyHeads.ToListAsync(); 151 if (!pheads.Select(x => x.Equals(pharmacyHead)).FirstOrDefault()) 152 { 153 await _context.PharmacyHeads.AddAsync(pharmacyHead); 154 await _context.SaveChangesAsync(); 155 } 156 } 149 157 } 150 158 … … 273 281 public async Task AddUser(User user) 274 282 { 275 await _context.Users.AddAsync(user); 276 await _context.SaveChangesAsync(); 283 if (user.Id == 0) 284 { 285 var users = await _context.Users.ToListAsync(); 286 if (!users.Select(x => x.Equals(user)).FirstOrDefault()) 287 { 288 await _context.Users.AddAsync(user); 289 await _context.SaveChangesAsync(); 290 } 291 } 277 292 } 278 293 }
Note:
See TracChangeset
for help on using the changeset viewer.