public async Task <IActionResult> AddUserInCustomersClub(string phoneNumber) { var mifare = new Mifare(); var contectDevice = mifare.ConnectDevice(); if (contectDevice.Status == "0") { return(new JsonResult(new { message = contectDevice.Message, status = contectDevice.Status })); } else { var connectCart = mifare.ConnectCart(); if (connectCart.Status == "0") { return(new JsonResult(new { message = connectCart.Message, status = connectCart.Status })); } else { var writeInfo = mifare.Write(phoneNumber); if (writeInfo.Status == "0") { return(new JsonResult(new { message = writeInfo.Message, status = writeInfo.Status })); } else { return(new JsonResult(new { status = "1", message = "با موفقیت ثبت شد", })); } } } }
public async Task <IActionResult> SearchUserByCart() { var mifare = new Mifare(); var phoneNumber = ""; var contectDevice = mifare.ConnectDevice(); if (contectDevice.Status == "0") { return(new JsonResult(new { message = contectDevice.Message, status = contectDevice.Status })); } else { var connectCart = mifare.ConnectCart(); if (connectCart.Status == "0") { return(new JsonResult(new { message = connectCart.Message, status = connectCart.Status })); } else { var readInfo = mifare.Read(); if (readInfo.Status == "0") { return(new JsonResult(new { message = readInfo.Message, status = readInfo.Status })); } else { phoneNumber = readInfo.PhoneNumber; var user = await _context.Users.Where(x => x.PhoneNumber.Equals(phoneNumber)).FirstOrDefaultAsync(); if (user != null) { return(new JsonResult(new { status = "1", message = "", url = "/Customer/ProductSale", result = user })); } else { return(new JsonResult(new { status = "0", message = "کاربری یافت نشد", url = "/Customer/ProductSale", })); } } } } }