Example #1
0
        public ActionResult CompleteJob(CompleteJobViewModel model)
        {
            string       userId  = User.Identity.GetUserId();
            LogicService cmLogic = new LogicService();

            //Send expense to logic
            bool expenseAdded = cmLogic.AddExpense(model.ExpenseToAdd.ExpenseName, model.ExpenseToAdd.ExpenseCost);

            if (expenseAdded)
            {
                //Add assign new expense to current job
                string expenseId       = cmLogic.GetExpenseIdByName(model.ExpenseToAdd.ExpenseName);
                bool   expenseAssigned = cmLogic.AssignExpense(model.JobId, expenseId, userId);

                if (expenseAssigned)
                {
                    return(RedirectToAction("CompleteJob", "Jobs", new { jobId = model.JobId }));
                }

                else
                {
                    return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Assign Expense" }));
                }
            }

            else
            {
                return(RedirectToAction("Result", "Dashboard", new { statusCode = 1, message = "Failed To Add Expense" }));
            }
        }