public async Task <ActionResult <TypeExpense> > PostTypeExpense(TypeExpense typeExpense) { _context.TypesExpense.Add(typeExpense); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTypeExpense", new { id = typeExpense.id }, typeExpense)); }
public async Task <IActionResult> PutTypeExpense(int id, TypeExpense typeExpense) { if (id != typeExpense.id) { return(BadRequest()); } _context.Entry(typeExpense).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeExpenseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static TypeExpense Convert(TypeExpenseDto typeExpenseDto) { if (typeExpenseDto == null) { return(null); } TypeExpense typeExpense = new TypeExpense(); typeExpense.Description = typeExpenseDto.Description; typeExpense.idType = typeExpenseDto.idType; typeExpense.Limited = typeExpenseDto.Limited; typeExpense.Title = typeExpenseDto.Title; return(typeExpense); }
public void AddExpense(TypeExpense cat, int cost, string currenty) { var e = new Expense(cat, cost, currenty) {UserId = _user.Username}; _validatorExpense.ValidItem(e); _expRepo.Save(e); }
public Expense(TypeExpense category, int cost, string currenty) { Category = category; Cost = cost; Currenty = currenty; }