Skip to content

Commit

Permalink
Merge pull request #164 from xdorro/minh
Browse files Browse the repository at this point in the history
Update Currency
  • Loading branch information
mizhm authored Aug 27, 2021
2 parents 95ff24e + 04aeb73 commit 532271b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 12 deletions.
40 changes: 37 additions & 3 deletions Backend/Areas/Admin/Controllers/CurrenciesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,52 @@ public ActionResult PutData(Currencies c)
// GET: Admin/Currencies/Delete/5
public ActionResult Delete(int id)
{
if (currencies.Delete(id))
try
{
var currency = currencies.Get(id);
if (currency == null)
{
return Json(new
{
statusCode = 400,
data = "This currency does not exist",
message = "Error"
}, JsonRequestBehavior.AllowGet);
}

if (currency.BankAccounts.Count > 0)
{
return Json(new
{
statusCode = 400,
data = "This currency have bank account link to it, cannot delete!",
message = "Error"
}, JsonRequestBehavior.AllowGet);
}

if (currencies.Delete(currency))
{
return Json(new
{
statusCode = 200,
message = "Success"
}, JsonRequestBehavior.AllowGet);
}
}
catch (System.Exception)
{
return Json(new
{
statusCode = 200,
message = "Success"
statusCode = 400,
data = "Something error happen",
message = "Error"
}, JsonRequestBehavior.AllowGet);
}

return Json(new
{
statusCode = 400,
data = "Something error happen",
message = "Error"
}, JsonRequestBehavior.AllowGet);
}
Expand Down
17 changes: 12 additions & 5 deletions Backend/Areas/Admin/Views/Currencies/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@
if (res.statusCode === 200) {
$("#modifyModal").modal("hide");
$('#datatables').DataTable().ajax.reload();
toastr.success('Created Successfully');
notifySuccess('Success', 'Created Successfully');
} else {
validator.showErrors(res.data);
notifyError('Error', 'Created Fail');
}
}
Expand All @@ -134,9 +135,10 @@
if (res.statusCode === 200) {
$("#modifyModal").modal("hide");
$('#datatables').DataTable().ajax.reload();
toastr.success('Updated Successfully');
notifySuccess('Success', 'Updated Successfully');
} else {
validator.showErrors(res.data);
notifyError('Error', 'Updated Fail');
}
}
})
Expand All @@ -156,9 +158,14 @@
$.ajax({
type: "GET",
url: `/Admin/Currencies/Delete/${id}`,
success: function () {
$('#datatables').DataTable().ajax.reload();
toastr.success('Deleted Successfully');
success: function (res) {
if (res.statusCode == 200) {
$('#datatables').DataTable().ajax.reload();
notifySuccess('Success', 'Deleted Successfully');
} else {
notifyError('Error', res.data);
}
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions Backend/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
</assemblyBinding>
</runtime>
<connectionStrings>
<add name="DBConnectionString" connectionString="server=.;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
<!-- <add name="DBConnectionString" connectionString="server=14.231.185.26;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" /> -->
<!--<add name="DBConnectionString" connectionString="server=.;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />-->
<add name="DBConnectionString" connectionString="server=14.231.185.26;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
Expand Down
2 changes: 1 addition & 1 deletion OnlineBanking.DAL/DataMapping/Currencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class Currencies

[Required(AllowEmptyStrings = false)] public string Name { get; set; }
public int Status { get; set; }
public ICollection<BankAccounts> BankAccounts { get; set; }
public virtual ICollection<BankAccounts> BankAccounts { get; set; }
}
}
2 changes: 1 addition & 1 deletion OnlineBanking.DAL/ViewModel/ProfileViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ProfileViewModel
[Required] [MinLength(10)] public string Phone { get; set; }
[Required] public string Birthday { get; set; }
[Required] public string Address { get; set; }
[Required] [MinLength(10)] public string NumberId { get; set; }
[Required] [MinLength(9)] public string NumberId { get; set; }
public string StatusName { get; set; } // active, delete, lock
public string RoleName { get; set; } // Quyền
}
Expand Down

0 comments on commit 532271b

Please sign in to comment.