コード例 #1
0
        public IActionResult Create([FromBody]  RealizationItem realizationItem)
        {
            _context.Add(realizationItem);

            _context.SaveChanges();
            return(CreatedAtRoute("GetRealizationItem", new { id = realizationItem.Id }, realizationItem));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        public void Register()
        {
            Users newUser = new Users
            {
                Login    = _userName,
                Password = _password,
                Email    = _email
            };

            _context.Users.Add(newUser);
            _context.SaveChanges();
        }
コード例 #6
0
        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();
        }