public ActionResult SaveTemperature()
        {
            //Get data from View to controller
            var memberNo          = Request.Form["txtMemberId"].ToString();
            var memberTemperature = Request.Form["txtTemperature"].ToString();

            try
            {
                decimal a = Convert.ToDecimal(memberTemperature);
                if (a <= 1)
                {
                    return(RedirectToAction(nameof(ErrorMessage)));
                }


                TemperatureViewModel model = new TemperatureViewModel
                {
                    MemberId          = Convert.ToInt32(memberNo),
                    TempuratureNumber = Convert.ToDecimal(memberTemperature),
                    //verifyNumber must set to Yes which 2 in the DB
                    VerifyId = 2
                };



                bool result = _TemperatureService.AddTemperature(model);
                if (result)
                {
                    Alert("Congratulations", "Temperature successfully recorded!", NotificationType.success);
                }
                else
                {
                    Alert("Error", "Temperature Failed to be recorded!", NotificationType.error);
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch (FormatException)
            {
                return(RedirectToAction(nameof(ErrorMessage)));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> PostTemp(RaspiTemp temps)
        {
            await _temperatureService.AddTemperature(temps);

            return(Ok());
        }