Example #1
0
        public ActionResult RemoveItem(int id)
        {
            var entity = ExpenseVoucherDetail.Find(id);

            if (entity.ExpenseVoucher.IsCancelled || entity.ExpenseVoucher.IsCompleted)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            using (var scope = new TransactionScope()) {
                entity.DeleteAndFlush();
            }

            return(Json(new { id = id, result = true }));
        }
Example #2
0
        public ActionResult SetItemComment(int id, string value)
        {
            ExpenseVoucherDetail item = ExpenseVoucherDetail.Find(id);

            if (item.ExpenseVoucher.IsCancelled || item.ExpenseVoucher.IsCompleted)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            if (!string.IsNullOrWhiteSpace(value))
            {
                using (var scope = new TransactionScope()) {
                    item.Comment = value.Length > 500 ? value.Substring(0, 500):value;
                    item.UpdateAndFlush();
                }
            }

            return(Json(new { id = id, value = item.Comment }));
        }
Example #3
0
        public ActionResult SetItemAmount(int id, decimal value)
        {
            ExpenseVoucherDetail item = ExpenseVoucherDetail.Find(id);

            if (item.ExpenseVoucher.IsCancelled || item.ExpenseVoucher.IsCompleted)
            {
                Response.StatusCode = 400;
                return(Content(Resources.ItemAlreadyCompletedOrCancelled));
            }

            if (value > 0)
            {
                using (var scope = new TransactionScope()) {
                    item.Amount = value;
                    item.UpdateAndFlush();
                }
            }

            return(Json(new { id = item.Id, value = item.FormattedValueFor(x => x.Amount) }));
        }
Example #4
0
        public ActionResult Item(int id)
        {
            var entity = ExpenseVoucherDetail.Find(id);

            return(PartialView("_ItemEditorView", entity));
        }