Skip to content

Commit

Permalink
Merge pull request #172 from xdorro/minh
Browse files Browse the repository at this point in the history
update transaction authorization
  • Loading branch information
mizhm authored Aug 27, 2021
2 parents 8ac79e8 + d0f049a commit 1819fea
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
24 changes: 24 additions & 0 deletions Backend/Controllers/ChequeBooksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ public ActionResult PostData()
public ActionResult PutData(int id)
{
var x = chequebooks.Get(id);
var user = (Accounts)Session["user"];
var account = accounts.Get(user.AccountId);

if (!chequebooks.CheckDuplicate(y => y.ChequeBookId == id && y.AccountId == account.AccountId))
{
return Json(new
{
statusCode = 404,
message = "Not found",
}, JsonRequestBehavior.AllowGet);
}

if (x.Status == (int)ChequeBookStatus.Deleted)
{
return Json(new
Expand Down Expand Up @@ -119,6 +131,18 @@ public ActionResult PutData(int id)
public ActionResult DeleteData(int id)
{
var x = chequebooks.Get(id);

var user = (Accounts)Session["user"];
var account = accounts.Get(user.AccountId);
if (!chequebooks.CheckDuplicate(y => y.ChequeBookId == id && y.AccountId == account.AccountId))
{
return Json(new
{
statusCode = 404,
message = "Not found",
}, JsonRequestBehavior.AllowGet);
}

if (x.Status == (int)ChequeBookStatus.Deleted)
{
return Json(new
Expand Down
17 changes: 12 additions & 5 deletions Backend/Controllers/TransactionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,18 +428,25 @@ private List<Notifications> CreateNotifications(Transactions transaction)

public ActionResult ProfileAccountNumber(int id)
{
if (((Accounts) Session["user"]) == null)
RedirectToAction("Login", "Home", new
{
area = ""
});
var user = (Accounts)Session["user"];
var account = accounts.Get(user.AccountId);
if (!bankAccounts.CheckDuplicate(x => x.BankAccountId == id && x.AccountId == account.AccountId))
{
return RedirectToAction("NotFound", "Error");
}
var data = bankAccounts.Get(x => x.BankAccountId == id).FirstOrDefault();
return data == null ? View() : View(data);
}

public ActionResult TransactionsDetails(int id)
{
var user = (Accounts) Session["user"];
var account = accounts.Get(user.AccountId);

if (!transactionDetails.CheckDuplicate(x => x.TransactionDetailId == id && x.BankAccount.AccountId == account.AccountId))
{
return RedirectToAction("NotFound", "Error");
}

var data = transactionDetails
.Get(x => x.TransactionDetailId == id && x.BankAccount.AccountId == user.AccountId)
Expand Down

0 comments on commit 1819fea

Please sign in to comment.