Example #1
0
        protected void btnKategori_Click(object sender, EventArgs e)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();
            var         kategori    = kategoriDAL.GetKategoriWithBerita(1);

            lblKategori.Text += $"Kategori: {kategori.nama_kat} <br/>";
            foreach (var b in kategori.Berita)
            {
                lblKategori.Text += $"Judul Berita: {b.judul_berita}";
            }
        }
Example #2
0
 public async Task DeleteKategori(int kategoriID)
 {
     try
     {
         KategoriDAL kategoriDAL = new KategoriDAL();
         await kategoriDAL.DeleteKategori(kategoriID);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #3
0
 public async Task UpdateKategori(Kategori kategori)
 {
     try
     {
         KategoriDAL kategoriDAL = new KategoriDAL();
         await kategoriDAL.UpdateKategori(kategori);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public async Task Update(Kategori obj)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            try
            {
                await kategoriDAL.Update(obj);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task Delete(string id)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            try
            {
                await kategoriDAL.Delete(id);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public async Task <IEnumerable <Kategori> > GetAll()
        {
            KategoriDAL kategoriDal = new KategoriDAL();

            try
            {
                return(await kategoriDal.GetAll());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #7
0
        public async Task TambahKategori(Kategori kategori)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            try
            {
                await kategoriDAL.TambahKategori(kategori);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        // PUT: api/Kategori/5
        public IHttpActionResult Put(Kategori kategori)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            try
            {
                kategoriDAL.Update(kategori);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        // DELETE: api/Kategori/5
        public IHttpActionResult Delete(int id)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            try
            {
                kategoriDAL.Delete(id);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #10
0
        //Sparar en kategori el updaterar en kontakt
        public void SaveKategori(KategoriTyp kategori)
        {
            //Valedering
            GetValidation((KategoriTyp)kategori);

            //insert eller update
            if (kategori.KategoriID == 0)
            {
                KategoriDAL.InsertKategori(kategori);
            }
            else
            {
                KategoriDAL.UpdateKategori(kategori);
            }
        }
        public async Task <Kategori> GetById(string id)
        {
            if (id == string.Empty)
            {
                throw new Exception("id harus diisi !");
            }

            KategoriDAL kategoriDal = new KategoriDAL();

            try
            {
                return(await kategoriDal.GetById(id));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #12
0
        //KATEGORITYPER CACHNING
        /// Hämtar alla kontakttyper.
        /// <returns>Ett List-objekt innehållande referenser till ContactType-objekt.</returns>
        public IEnumerable <KategoriTyp> GetKategoriTypes(bool refresh = false)
        {
            // Försöker hämta lista med kontakttyper från cachen.
            var kategoriTypes = HttpContext.Current.Cache["KategoriTypes"] as IEnumerable <KategoriTyp>;

            // Om det inte finns det en lista med kontakttyper...
            if (kategoriTypes == null || refresh)
            {
                // ...hämtar då lista med kontakttyper...
                kategoriTypes = KategoriDAL.GetKategorier();

                // ...och cachar dessa. List-objektet, inklusive alla ContactType-objekt, kommer att cachas
                // under 10 minuter, varefter de automatiskt avallokeras från webbserverns primärminne.
                HttpContext.Current.Cache.Insert("KategoriTypes", kategoriTypes, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero);
            }

            // Returnerar listan med kontakttyper.
            return(kategoriTypes);
        }
Example #13
0
 public SampleModelBinding()
 {
     kategoriDal = new KategoriDAL();
 }
        public IEnumerable <Kategori> Get(string namaKategori)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            return(kategoriDAL.SearchByName(namaKategori));
        }
Example #15
0
        public async Task <Kategori> GetKategoriByID(int kategoriID)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            return(await kategoriDAL.GetKategoriByID(kategoriID));
        }
Example #16
0
 public SampleSOAP()
 {
     kategoriDAL = new KategoriDAL();
 }
        // GET: api/Kategori/5
        public Kategori Get(int id)
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            return(kategoriDAL.GetById(id));
        }
        // GET: api/Kategori
        public IEnumerable <Kategori> Get()
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            return(kategoriDAL.GetAll());
        }
Example #19
0
 public List <Kategori> GetAll()
 {
     kategoriDAL = new KategoriDAL();
     return(kategoriDAL.GetAll().ToList());
 }
Example #20
0
 //Metoder KATEGORITYP
 //Hämtar ALLA Kategorier
 public IEnumerable <KategoriTyp> GetKategorier()
 {
     return(KategoriDAL.GetKategorier());
 }
Example #21
0
        public async Task <IEnumerable <Kategori> > GetAllKategori()
        {
            KategoriDAL kategoriDAL = new KategoriDAL();

            return(await kategoriDAL.GetAllKategori());
        }
Example #22
0
 // The return type can be changed to IEnumerable, however to support
 // paging and sorting, the following parameters must be added:
 //     int maximumRows
 //     int startRowIndex
 //     out int totalRowCount
 //     string sortByExpression
 public IQueryable <SampleEF.Data.Kategori> gvKategori_GetData()
 {
     kategoriDal = new KategoriDAL();
     return(kategoriDal.GetAll());
 }
Example #23
0
 //Hämtar EN kategori
 public KategoriTyp GetKategori(int kategoriId)
 {
     return(KategoriDAL.GetKategoriById(kategoriId));
 }
Example #24
0
 public SampleADO()
 {
     kategoriDAL = new KategoriDAL();
 }
Example #25
0
 //Tar bort en kategori
 public void DeleteKategoriTyp(KategoriTyp kategori)
 {
     KategoriDAL.DeleteKategoriTyp(kategori);
 }