public bool Post([FromBody] UpdatePredictionRequest prediction)
        {
            Console.WriteLine("Update Prediction " + prediction);
            if (Hook.IsAdminSessionRegistered(prediction.SessionToken))
            {
                var dbConnection     = new ZodiacDbConnection();
                var predictionToSave = new Prediction(
                    dbConnection.GetZodiac((ZodiacType)Convert.ToInt32(prediction.Zodiac)),
                    dbConnection.GetTimeInterval((TimeIntervalType)Convert.ToInt32(prediction.TimeInterval)),
                    prediction.Text);
                dbConnection.SaveOrUpdate(predictionToSave);
                return(true);
            }

            Console.WriteLine($"Illegal access, {prediction.SessionToken} isn't registered!");
            return(false);
        }
Exemplo n.º 2
0
        public bool Post([FromBody] UpdateCompatibilityRequest compatibilityRequest)
        {
            Console.WriteLine("Update Compatibility " + compatibilityRequest);
            if (Hook.IsAdminSessionRegistered(compatibilityRequest.SessionToken))
            {
                var dbConnection        = new ZodiacDbConnection();
                var compatibilityToSave = new Compatibility(
                    dbConnection.GetCompatibility((ZodiacType)compatibilityRequest.ZodiacType1,
                                                  (ZodiacType)compatibilityRequest.ZodiacType2).Id,
                    dbConnection.GetZodiac((ZodiacType)Convert.ToInt32(compatibilityRequest.ZodiacType1)),
                    dbConnection.GetZodiac((ZodiacType)Convert.ToInt32(compatibilityRequest.ZodiacType2)),
                    compatibilityRequest.CompatibilityValue, compatibilityRequest.Text);
                dbConnection.SaveOrUpdate(compatibilityToSave);
                return(true);
            }

            Console.WriteLine($"Illegal access, token '{compatibilityRequest.SessionToken}' isn't registered!");
            return(false);
        }
Exemplo n.º 3
0
        public bool Post([FromForm] UpdateHaircutRequest request)
        {
            Console.WriteLine("Update Haircut " + request);
            if (Hook.IsAdminSessionRegistered(request.SessionToken))
            {
                var isPositive = request.IsPositive != null;

                var dbConnection = new ZodiacDbConnection();
                dbConnection.SaveOrUpdate(new Haircut(
                                              request.Id,
                                              dbConnection.GetZodiac(request.ZodiacId),
                                              request.MoonDay,
                                              request.MoonPhase,
                                              request.Prediction,
                                              isPositive
                                              ));
                return(true);
            }

            Console.WriteLine($"Illegal access, {request.SessionToken} isn't registered!");
            return(false);
        }