public async Task Update(OperationTypeDto t) { using (SpendingsDBContext context = new SpendingsDBContext()) { OperationType toUpdate = Mapper.Map <OperationTypeDto, OperationType>(t); context.OperationTypes.Attach(toUpdate); context.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; await context.SaveChangesAsync(); } }
public async Task Update(AccountDto t) { using (SpendingsDBContext context = new SpendingsDBContext()) { //Account toUpdate = context.Accounts.FirstOrDefault(d => d.Id == t.Id); //toUpdate.Name = t.Name; //toUpdate.IdCurrency = t.IdCurrency; Account toUpdate = Mapper.Map <AccountDto, Account>(t); context.Accounts.Attach(toUpdate); context.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; await context.SaveChangesAsync(); } }