private DbHolder ToDbHolder(DTOHolder item) { var holder = _bankContext.Holders.Find(item.Id) ?? throw new InvalidOperationException("Holder not found, incorrect id!"); var accounts = ToAccounts(item.Accounts); return(HolderMapper.UpdateDbHolder(item, holder, accounts)); }
public void Add(DTOHolder item) { var holder = new DbHolder { Id = item.Id }; var accounts = ToAccounts(item.Accounts); holder = HolderMapper.UpdateDbHolder(item, holder, accounts); _bankContext.Holders.Add(holder); }