Beispiel #1
0
        public ActionResult AddBillingTerm(BillingTerm addedTerm)
        {
            // Add the term to the database
            var result = _processor.AddBillingTerm(addedTerm);

            // Return either the updated list or an error message
            if (result.IsSuccessful)
            {
                return(GetBillingTerms());
            }

            return(Content(result.ErrorMessage));
        }
Beispiel #2
0
        public ActionResult SaveBillingTerm(BillingTerm term, string oper, string id)
        {
            IOpResult result;

            switch (oper)
            {
            case "edit":
                result = _processor.UpdateBillingTerm(term);
                break;

            case "add":
                result = _processor.AddBillingTerm(term);
                break;

            case "del":
                result = _processor.DeleteBillingTerm(int.Parse(id));
                break;

            default:
                result = new OpResult
                {
                    IsSuccessful = false,
                    ErrorMessage = string.Format("{0} is an unsupported operation.", oper)
                };
                break;
            }

            // Return an empty string
            if (result.IsSuccessful)
            {
                return(Content(string.Empty));
            }

            // Return the error message
            HttpContext.Response.StatusCode = 500;
            return(Content(result.ErrorMessage));
        }