Exemplo n.º 1
0
        public IActionResult Input()
        {
            if (!MyUser.Login(Cookie.GetUuid()))
            {
                throw new Exception();
            }

            ViewData["MySubjects"] = Subjects.GetMine(MyUser.GetId());

            return(View());
        }
Exemplo n.º 2
0
        public IActionResult Index()
        {
            if (!MyUser.Login(Cookie.GetUuid()))
            {
                MyUser.CreateUser();
            }

            ViewData["Subjects"] = Subjects.GetAllWithMyVote(MyUser.GetId());
            ViewData["Now"]      = Infos.GetNowSubjectId();
            return(View());
        }
        public string Create([FromBody] JsonElement body)
        {
            if (!MyUser.Login(Cookie.GetUuid()))
            {
                throw new Exception();
            }

            Create inputs = JsonSerializer.Deserialize <Create>(body.ToString());

            inputs.Validate();
            Subjects.Create(MyUser.GetId(), inputs.Title, inputs.Artist, inputs.Url, inputs.Comment);
            return(Utility.ApiResponse(new { is_success = true }));
        }
        public string Vote([FromBody] JsonElement body)
        {
            if (!MyUser.Login(Cookie.GetUuid()))
            {
                throw new Exception();
            }

            Vote inputs = JsonSerializer.Deserialize <Vote>(body.ToString());

            inputs.Validate();
            SubjectVotes.Replace(
                Convert.ToInt32(inputs.SubjectId),
                Convert.ToInt32(MyUser.GetId()),
                Convert.ToInt32(inputs.Point),
                inputs.Comment
                );

            return(Utility.ApiResponse(new { is_success = true }));
        }