Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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();
            }
        }