V
V
Vanik Khachatryan2018-09-29 17:59:26
ASP.NET
Vanik Khachatryan, 2018-09-29 17:59:26

Why doesn't ModelState.IsValid become False even though Remote returns false?

Why doesn't ModelState.IsValid become false even though Remote returns false?
Is the check done for enough money in the account for the transaction?
Model:

[Required(ErrorMessage = "Введите сумму ставки")]
        [Range(MinBetSum, MaxBetSum, ErrorMessage = "Сумма от 50 до 50000")]
        [Remote(action: "InCash", controller: "Validate", ErrorMessage = "Недостаточно средств")]
        public decimal Sum{ get; set; }

Validation in controller: Validator:
ModelState.IsValid == false
[AcceptVerbs("Get")]
        public async Task<JsonResult> InCash(decimal Sum)
        {
            User user = await db.Users.FirstOrDefaultAsync(u => u.Username == User.Identity.Name);
            bool res = user.Balance >= Sum;

            return Json(res);
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question