public childApprovalDetails ApproveForPayday(int choreId) { var changedChoresStatus = Repository.Table <Chore>().Where(p => p.Id == choreId).FirstOrDefault(); if (changedChoresStatus.BankTransactionID != null) { var chkBankTransaction = Repository.Table <BankTransaction>().Where(p => p.Id == changedChoresStatus.BankTransactionID).FirstOrDefault(); if (chkBankTransaction.TransactionStatus == TransactionStatus.Pending) { changedChoresStatus.ChoreStatus = ChoreStatus.CompletedAndApproved; changedChoresStatus.ApprovedApprovalDate = DateTime.UtcNow; } else if (chkBankTransaction.TransactionStatus == TransactionStatus.Completed) { changedChoresStatus.ChoreStatus = ChoreStatus.CompletedAndPaid; changedChoresStatus.ApprovedApprovalDate = DateTime.UtcNow; } } else { changedChoresStatus.ChoreStatus = ChoreStatus.Completed; changedChoresStatus.ApprovedApprovalDate = DateTime.UtcNow; } Repository.Update(changedChoresStatus); //Set var childReturnStatus = new childApprovalDetails { ApprovalStatus = changedChoresStatus.ChoreStatus, Amount = changedChoresStatus.Value }; return(childReturnStatus); }
//added by stpl public childApprovalDetails RemoveApprovalService(int choreId) { var changedChoresStatus = Repository.Table <Chore>().Where(p => p.Id == choreId).FirstOrDefault(); if ((changedChoresStatus.ChoreStatus == ChoreStatus.Completed && changedChoresStatus.BankTransactionID == null) || (changedChoresStatus.ChoreStatus == ChoreStatus.CompletedAndApproved && changedChoresStatus.BankTransactionID == null)) { changedChoresStatus.ChoreStatus = ChoreStatus.DisApproved; changedChoresStatus.RemoveAprovalDate = DateTime.UtcNow; } else if ((changedChoresStatus.ChoreStatus == ChoreStatus.CompletedAndApproved && changedChoresStatus.BankTransactionID != null)) { changedChoresStatus.ChoreStatus = ChoreStatus.DisapprovedAndPending; changedChoresStatus.RemoveAprovalDate = DateTime.UtcNow; } else if ((changedChoresStatus.ChoreStatus == ChoreStatus.CompletedAndPaid && changedChoresStatus.BankTransactionID != null)) { changedChoresStatus.ChoreStatus = ChoreStatus.DisapprovedAndPending; changedChoresStatus.RemoveAprovalDate = DateTime.UtcNow; } Repository.Update(changedChoresStatus); //Set var childReturnStatus = new childApprovalDetails { ApprovalStatus = changedChoresStatus.ChoreStatus, Amount = changedChoresStatus.Value }; return(childReturnStatus); }