protected override async Task DoUpdate(ApplicationUserModel model, string id, ApplicationUser entity) { SharedGroupContact sharedGroupContact = await context.Set <SharedGroupContact>().FirstOrDefaultAsync(p => p.GroupId == model.SharedGroupId && p.ShareToUserId == model.Id); if (sharedGroupContact != null) { await context.DeleteAsync(sharedGroupContact); } }
protected override async Task <ApplicationUser> DoCreate(ApplicationUserModel model, ApplicationUser entity) { if (!context.Set <SharedGroupContact>().Any(p => p.GroupId == model.SharedGroupId && p.ShareToUserId == model.Id)) { var sharedGroupContact = new SharedGroupContact(); sharedGroupContact.GroupId = model.SharedGroupId.Value; sharedGroupContact.ShareToUserId = model.Id; sharedGroupContact = await context.InsertAsync(sharedGroupContact); } return(entity); }