Exemplo n.º 1
0
        public static ExpenseDetailsResponse GetExpenseDetails(ExpenseDetailsRequest request)   //Get Details for a specific Expense
        {
            int ExpenseID = request.ExpenseID;

            var response = new ExpenseDetailsResponse();
            var expense  = new ExpenseDomain();

            using (var entities = new ExpenseProjectDBEntities())
            {
                expense = (from e in entities.Expenses
                           where (e.ID == ExpenseID)
                           select new ExpenseDomain
                {
                    ID = e.ID,
                    TotalAmount = e.TotalAmount,
                    CreatedDate = e.CreatedDate,
                    CreatedUserID = e.Created_User,
                    StatusID = e.StatusId,
                    ModifiedByID = e.ModifiedBy,
                    ModifiedDate = e.ModifiedDate,
                    RejectDescription = e.RejectDescription
                }
                           ).FirstOrDefault();

                response.ExpenseInformation = expense;
                response.ExpenseItemList    = GetExpenseItems(request);

                return(response);
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult GetExpensesByExpenseID(ExpenseDetailsRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var response = ExpenseHandler.GetExpenseDetails(request);

            return(Ok(response));
        }
Exemplo n.º 3
0
        public static List <ExpenseItemDomain> GetExpenseItems(ExpenseDetailsRequest request)   //Get all Expense Items of one Expense
        {
            int ExpenseID = request.ExpenseID;

            List <ExpenseItemDomain> response = new List <ExpenseItemDomain>();

            using (var entities = new ExpenseProjectDBEntities())
            {
                response = (from e in entities.ExpenseItems
                            where (e.ExpenseId == ExpenseID)
                            select new ExpenseItemDomain
                {
                    ExpenseItemID = e.ID,
                    ExpenseItemDescription = e.ExpenseDescription,
                    ExpenseItemAmount = e.ExpenseAmount,
                    ExpenseItemDate = e.ExpenseDate
                }
                            ).ToList();

                return(response);
            }
        }