Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
1
Indexable
Never
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;

namespace StudentManagementSystem.Controllers
{
    public class CourseController: ApiController //Extends(Kalıtım)
    {
        StudentManagementSystemEntities sms = new StudentManagementSystemEntities();

        StudentCourseController scc1 = new StudentCourseController();

        [HttpGet]
        public List<CourseInformation> DersSil(int CID)
        {
            scc1.OgrenciDersSilOgrenciIDGore(CID);
            sms.Course.Remove(sms.Course.Find(CID));
            sms.SaveChanges();
            return TumDersleriGetir();

        }


        [HttpGet]
        public List<CourseInformation> TumDersleriGetir()
        {
            return sms.Course.Select(p => new CourseInformation()
            {
                CID = p.CID,
                CAKTS = p.CAKTS,
                CName = p.CName,
                CDetail = p.CDetail,
                CKredi = p.CKredi
            }
            ).ToList(); //Veri tabanından ders tablosundan tür dönüşümü yaparak getir
        }


    }

    public class CourseInformation
    {
        public short CID { get; set; }
        public string CName { get; set; }
        public string CDetail { get; set; }
        public byte CKredi { get; set; }
        public byte CAKTS { get; set; }

    }
}