コード例 #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 ActionResult Create([Bind(Include = "Id,ProgramKodu,ProgramAdi,PuanTuru,Kontenjan,Yerlesen,EnKucukPuan,EnBuyukPuan,UserlId")] MyViewModel myViewModel)
        {
            if (ModelState.IsValid)
            {
                db.Tercihler.Add(myViewModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(myViewModel));
        }
コード例 #3
0
        // Kişinin Id sine göre Listesine ekleme Yapıyoruz
        public ActionResult Ekle(string ProgramKodu, string ProgramAdi, string PuanTuru, string Kontenjan, string Yerlesen, double EnKucukPuan, double EnBuyukPuan)
        {
            var         userId = User.Identity.GetUserId();
            MyViewModel model  = new MyViewModel();

            model.ProgramKodu = ProgramKodu;
            model.ProgramAdi  = ProgramAdi;
            model.PuanTuru    = PuanTuru;
            model.Kontenjan   = Kontenjan;
            model.Yerlesen    = Yerlesen;
            model.EnKucukPuan = EnKucukPuan;
            model.EnBuyukPuan = EnBuyukPuan;
            model.UserlId     = userId;
            tercihContext.Tercihler.Add(model);
            tercihContext.SaveChanges();

            return(RedirectToAction("Index", "Home"));


            // return View();
        }
コード例 #4
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());
            }
        }