public void DeleteExpenseTest()
        {
            var expense1 = GetNewMockExpense(collaborator.CollaboratorId, expenseStory.ExpenseStoryId);
            var expense2 = GetNewMockExpense(collaborator.CollaboratorId, expenseStory.ExpenseStoryId);
            var expense3 = GetNewMockExpense(collaborator.CollaboratorId, expenseStory.ExpenseStoryId);

            expenseManager.AddExpense(expense1);
            expenseManager.AddExpense(expense2);
            expenseManager.AddExpense(expense3);

            expenseManager.DeleteExpense(expense1.ExpenseId);
            var isExists = dataContext.Expense.Any(x => x.ExpenseId == expense1.ExpenseId);

            Assert.IsFalse(isExists);
        }
Example #2
0
        public HttpResponseMessage DeleteExpense(int ExpenseID)
        {
            ExpenseManager       expenseManager      = new ExpenseManager();
            cls_common_responses clsCommonResponses1 = new cls_common_responses();
            HttpResponseMessage  response;

            try
            {
                cls_common_responses clsCommonResponses2 = expenseManager.DeleteExpense(ExpenseID);
                int responseCode = clsCommonResponses2.ResponseCode;
                response = this.Request.CreateResponse <cls_common_responses>(HttpStatusCode.OK, clsCommonResponses2);
            }
            catch (Exception ex)
            {
                clsCommonResponses1.ResponseCode    = 400;
                clsCommonResponses1.ResponseMessage = "Something went wrong, please try again later.";
                response = this.Request.CreateResponse <cls_common_responses>(HttpStatusCode.OK, clsCommonResponses1);
            }
            return(response);
        }
Example #3
0
        private async void DeleteButtonClicked(object sender, EventArgs e)
        {
            var expenseName = Description.Text;
            //var expenseDate =
            var expenseAmount = float.Parse(ExpenseAmount.Text);
            var category      = (string)picker.SelectedItem;

            Enum.TryParse(category, out ExpenseCategory myCategory);

            //here we did binding context, to edit the values of the expense
            if (BindingContext != null)
            {
                var expense = (Expense)BindingContext;
                expense.ExpenseName = expenseName;
                expense.Amount      = expenseAmount;
                expense.Date        = File.GetCreationTime(expense.FileName);
                expense.Category    = myCategory;
                ExpenseManager.DeleteExpense(expense);
            }

            await Navigation.PopModalAsync();
        }
        // DELETE: api/Expense/5

        public void Delete(int id)
        {
            ExpenseManager.DeleteExpense(id);
        }