Esempio n. 1
0
        public ActionResult Create(ExpenseSummary expenseSummary)
        {
            try
            {
                try
                {
                    ExpenseManager expenseManager = new ExpenseManager();
                    expenseSummary.EmpID = Convert.ToInt32(Session["UserID"]);
                    int value = expenseManager.CreateExpense(expenseSummary);

                    if (value == 1)
                    {
                        TempData["Message"] = "Expense Created Successfully";
                    }

                    else if (value == 0)
                    {
                        TempData["Message"] = "Error Occured";
                    }
                    return(Redirect("~/Expense/Index"));
                }
                catch (Exception ex)
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
 // POST: api/Expense
 public bool Post([FromBody] Expense value)
 {
     if (value.Amount > 0)
     {
         ExpenseManager.CreateExpense(value);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
        public NewExpenseResponseModel NewExpense([FromBody] NewExpenseRequestModel model)
        {
            if (model == null)
            {
                return new NewExpenseResponseModel()
                       {
                           ErrorMessage = "Model is not valid", IsSuccess = false, ResultCode = "Error"
                       }
            }
            ;

            var expense = new Expense();

            expense.CompanyName = model.CompanyName;
            expense.CustomerNo  = model.CustomerNo;
            expense.Price       = model.Price;

            ExpenseManager.CreateExpense(expense);

            var customer = CustomerManager.GetCustomerByNo(model.CustomerNo);

            var informationModel = new InformationModel();

            informationModel.date  = DateTime.Now;
            informationModel.email = customer.Email;
            informationModel.price = model.Price;

            AddQueue(informationModel);

            var response = new NewExpenseResponseModel();

            response.IsSuccess  = true;
            response.ResultCode = "Success";

            return(response);
        }