private void MapChange(BankProjectModelsDataContext dbContext, AccountPeriod accountPeriod, EntityAccountPeriod existEntity) { existEntity.Title = accountPeriod.Title; existEntity.AvailableSlot = accountPeriod.AvailableSlot; existEntity.BeginPeriod = accountPeriod.BeginPeriod; existEntity.EndPeriod = accountPeriod.EndPeriod; existEntity.UserId = accountPeriod.UserId; existEntity.IsEnabled = accountPeriod.IsEnabled; existEntity.IsBlocked = accountPeriod.IsBlocked; existEntity.WorkingDay = (int)accountPeriod.WorkingDay; var currentShiftIds = accountPeriod.Shifts.Select(x => x.Id).ToArray(); var originalShifts = existEntity.AccountShifts.ToList(); foreach (var accountShift in originalShifts) { if (!currentShiftIds.Contains(accountShift.ShiftId)) { existEntity.AccountShifts.Remove(accountShift); dbContext.AccountShifts.DeleteOnSubmit(accountShift); } } foreach (var shiftId in currentShiftIds) { if (existEntity.AccountShifts.All(x => x.ShiftId != shiftId)) { var newAccountShift = new AccountShift { AccountPeriodId = accountPeriod.Id, ShiftId = shiftId }; existEntity.AccountShifts.Add(newAccountShift); dbContext.AccountShifts.InsertOnSubmit(newAccountShift); } } }
private void detach_AccountShifts(AccountShift entity) { this.SendPropertyChanging(); entity.AccountPeriod = null; }
private void attach_AccountShifts(AccountShift entity) { this.SendPropertyChanging(); entity.Shift = this; }
partial void DeleteAccountShift(AccountShift instance);
partial void UpdateAccountShift(AccountShift instance);
partial void InsertAccountShift(AccountShift instance);