public IHttpActionResult Post(CkExpenseCreate ckExpense)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateCkExpenseService();

            if (!service.CreateExpense(ckExpense))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Beispiel #2
0
        public bool CreateExpense(CkExpenseCreate model)
        {
            var entity =
                new CkExpense()
            {
                CkExpenseId     = model.CkExpenseId,
                AccountId       = model.AccountId,
                CkExpenseAmount = model.CkExpenseAmount,
                CkExpenseName   = model.CkExpenseName,
                CkDueDate       = model.CkDueDate
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.CkExpenses.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }