123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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(Syllabus root) {
- return await _aAzureCosmosDBRepository.Save<Syllabus>(root);
- }
- [HttpGet]
- [Route("getById")]
- [EnableCors("any")]
- [AllowAnonymous]
- public object GetById(string id )
- {
- var ss = _aAzureCosmosDBRepository.FindAll<Syllabus>().Result.Where(s => s.id == id).ToList().SingleOrDefault();
- if (ss != null) {
- return ss;
- }
- else { return ""; }
-
- }
- [HttpGet]
- [Route("getAll")]
- [EnableCors("any")]
- [AllowAnonymous]
- public object GetAll()
- {
- List<Syllabus>syllabi= _aAzureCosmosDBRepository.FindAll<Syllabus>().Result;
- if (syllabi != null)
- {
- return syllabi;
- }
- else { return ""; }
- }
- }
- }
|