Esempio n. 1
0
 public IActionResult Get()
 {
     try
     {
         return(Json(new ApiResultGeneric <IEnumerable <int> >(raffleService.DoRaffle())));
     }
     catch (Exception ex)
     {
         return(Json(ApiResultBase.GetByErrorCode(ErrorCode.InternalServerError)));
     }
 }
 public IActionResult Get()
 {
     try
     {
         return(Json(new ApiResultGeneric <IEnumerable <City> >(mockService.GetCities())));
     }
     catch (Exception ex)
     {
         return(Json(ApiResultBase.GetByErrorCode(ErrorCode.InternalServerError)));
     }
 }
 public IActionResult Get(int id)
 {
     try
     {
         var data = mockService.GetCityById(mockService.GetCities(), id);
         return(Json(new ApiResultGeneric <City>(data)));
     }
     catch (Exception ex)
     {
         return(Json(ApiResultBase.GetByErrorCode(ErrorCode.InternalServerError)));
     }
 }
        public IActionResult Get()
        {
            try
            {
                var users = userService.GetUsers();

                return(Json(new ApiResultGeneric <IEnumerable <User> >(users)));
            }
            catch (Exception ex)
            {
                return(Json(ApiResultBase.GetByErrorCode(ErrorCode.InternalServerError)));
            }
        }
        public IActionResult Login([FromBody] LoginModel model)
        {
            try
            {
                var  password   = Encoding.UTF8.GetString(Convert.FromBase64String(model.Password));
                User loggedUser = userService.CheckUserCredentials(model.Email, password);
                if (loggedUser == null)
                {
                    return(Json(ApiResultBase.GetByErrorCode(ErrorCode.InvalidLogin)));
                }

                return(Json(new ApiResultGeneric <long>(loggedUser.UserID)));
            }
            catch (Exception ex)
            {
                return(Json(ApiResultBase.GetByErrorCode(ErrorCode.InternalServerError)));
            }
        }