12345678910111213141516171819202122232425262728293031323334353637383940 |
- using HaBookCms.AzureCosmos.CosmosDB.Interfaces;
- using HaBookCms.Core.Models.Syllabus;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Cors;
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace HaBookCms.Contest.Controllers
- {
- [Route("api/syllabus")]
- [ApiController]
- public class SyllabusController : BaseController
- {
- public IAzureCosmosDBRepository _aAzureCosmosDBRepository;
- public SyllabusController(IAzureCosmosDBRepository aAzureCosmosDBRepository) {
- _aAzureCosmosDBRepository = aAzureCosmosDBRepository;
- }
- [HttpPost]
- [Route("save")]
- [EnableCors("any")]
- [AllowAnonymous]
- public async Task<object> Save(SyllabusRoot root) {
- return await _aAzureCosmosDBRepository.Save<SyllabusRoot>(root);
- }
- [HttpGet]
- [Route("getById")]
- [EnableCors("any")]
- [AllowAnonymous]
- public object GetById()
- {
- return _aAzureCosmosDBRepository.FindAll<SyllabusRoot>().Result.FirstOrDefault();
- }
- }
- }
|