예제 #1
0
        public bool UpdateRetExpense(RetExpenseEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .RetExpenses
                    .Single(e => e.RetExpenseId == model.RetExpenseId);

                entity.RetExpenseAmount = model.RetExpenseAmount;
                entity.RetExpenseName   = model.RetExpenseName;
                entity.RetDueDate       = model.RetDueDate;

                return(ctx.SaveChanges() == 1);
            }
        }
예제 #2
0
        public IHttpActionResult Put(RetExpenseEdit retExpense)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateRetExpenseService();

            if (!service.UpdateRetExpense(retExpense))
            {
                return(InternalServerError());
            }

            return(Ok());
        }