public IActionResult Create([FromBody] RealizationItem realizationItem) { _context.Add(realizationItem); _context.SaveChanges(); return(CreatedAtRoute("GetRealizationItem", new { id = realizationItem.Id }, realizationItem)); }
public IActionResult Create([FromBody] Category category) { if (category == null) { return(BadRequest()); } _context.Categories.Add(category); _context.SaveChanges(); return(CreatedAtRoute("GetCategory", new { id = category.Id }, category)); }
public IActionResult Create() { Objective objective = new Objective(); objective.Category = new Category { Id = -1 }; _context.Add(objective); _context.SaveChanges(); return(CreatedAtRoute("GetObjective", new { id = objective.Id }, objective)); }
public void Edit(IEditableExpenseProperties newValues) { Expense.Date = newValues.Date; Expense.Name = newValues.Name; Expense.CategoryId = newValues.CategoryId; Expense.TotalPrice = newValues.TotalPrice; Expense.Quantity = newValues.Quantity; Expense.UnitId = newValues.UnitId; context.SaveChanges(); }
public void Register() { Users newUser = new Users { Login = _userName, Password = _password, Email = _email }; _context.Users.Add(newUser); _context.SaveChanges(); }
public void Add(IAddingExpenseInputs expenseInputs, int userId) { var expense = new Expenses { UserId = userId, CategoryId = expenseInputs.SelectedCategoryId, UnitId = expenseInputs.SelectedUnitId, Name = expenseInputs.ProductName, TotalPrice = expenseInputs.Price.Value, Quantity = expenseInputs.Quantity, Date = expenseInputs.Date }; context.Expenses.Add(expense); context.SaveChanges(); }