Beispiel #1
0
        public async Task <ActionResult <TypeExpense> > PostTypeExpense(TypeExpense typeExpense)
        {
            _context.TypesExpense.Add(typeExpense);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTypeExpense", new { id = typeExpense.id }, typeExpense));
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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);
 }
Beispiel #5
0
 public Expense(TypeExpense category, int cost, string currenty)
 {
     Category = category;
     Cost = cost;
     Currenty = currenty;
 }