Пример #1
0
        public IHttpActionResult PutTercihVeriModel(int id, TercihVeriModel tercihVeriModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tercihVeriModel.Id)
            {
                return(BadRequest());
            }

            db.Entry(tercihVeriModel).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TercihVeriModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetTercihVeriModel(int id)
        {
            TercihVeriModel tercihVeriModel = db.TercihVerileri.Find(id);

            if (tercihVeriModel == null)
            {
                return(NotFound());
            }

            return(Ok(tercihVeriModel));
        }
Пример #3
0
        public IHttpActionResult PostTercihVeriModel(TercihVeriModel tercihVeriModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TercihVerileri.Add(tercihVeriModel);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tercihVeriModel.Id }, tercihVeriModel));
        }
Пример #4
0
        public IHttpActionResult DeleteTercihVeriModel(int id)
        {
            TercihVeriModel tercihVeriModel = db.TercihVerileri.Find(id);

            if (tercihVeriModel == null)
            {
                return(NotFound());
            }

            db.TercihVerileri.Remove(tercihVeriModel);
            db.SaveChanges();

            return(Ok(tercihVeriModel));
        }
Пример #5
0
        public ActionResult DosyaEkle(HttpPostedFileBase excelFile)
        {
            if (excelFile == null ||
                excelFile.ContentLength == 0)
            {
                ViewBag.Error = "Lütfen dosya seçimi yapınız.";

                return(View());
            }
            else
            {
                if (excelFile.FileName.EndsWith("xls") ||
                    excelFile.FileName.EndsWith("xlsx"))
                {
                    //Seçilen dosyanın nereye kaydedileceği belirtiliyor.
                    string path = Server.MapPath("~/Veri/" + excelFile.FileName);

                    //Dosya kontrol edilir, varsa silinir.
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }

                    //Excel path altına kaydedilir.
                    excelFile.SaveAs(path);

                    using (var excelWorkbook = new XLWorkbook(path))
                    {
                        var nonEmptyDataRows = excelWorkbook.Worksheet(1).RowsUsed();


                        foreach (var dataRow in nonEmptyDataRows)
                        {
                            TercihContext tercihContext = new TercihContext();
                            //for row number check
                            TercihVeriModel model = new TercihVeriModel();
                            if (dataRow.RowNumber() > 1 && dataRow.Cell(1).Value.ToString() != "Program Kodu" &&
                                dataRow.Cell(1).Value.ToString() != "TABLO-4 Merkezi Yerleştirme İle Öğrenci Alan Yükseköğretim Lisans Programları" &&
                                dataRow.Cell(1).Value.ToString() != "TABLO-3 Merkezi Yerleştirme İle Öğrenci Alan Yükseköğretim Önlisans Programları" &&
                                dataRow.Cell(1).Value.ToString() != ""
                                )
                            {   //TAblo verileribi Gönderdiğim Yer
                                model.ProgramKodu = dataRow.Cell(1).Value.ToString();
                                model.ProgramAdi  = dataRow.Cell(2).Value.ToString();
                                model.PuanTuru    = dataRow.Cell(3).Value.ToString();
                                model.Kontenjan   = dataRow.Cell(4).Value.ToString();
                                model.Yerlesen    = dataRow.Cell(5).Value.ToString();
                                if (dataRow.Cell(6).Value.ToString() == "--")
                                {
                                    model.EnKucukPuan = 0;
                                }
                                else
                                {
                                    model.EnKucukPuan = dataRow.Cell(6).GetDouble();
                                }
                                if (dataRow.Cell(7).Value.ToString() == "--")
                                {
                                    model.EnBuyukPuan = 0;
                                }
                                else
                                {
                                    model.EnBuyukPuan = dataRow.Cell(7).GetDouble();
                                }


                                tercihContext.TercihVerileri.Add(model);
                                tercihContext.SaveChanges();
                            }
                        }
                    }
                }

                return(View());
            }
        }