예제 #1
0
        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";
            var    egitim = veritabani.EgitimTablo.ToList();
            Random rnd    = new Random();

            foreach (var item in egitim)
            {
                EgitimTablo et = new EgitimTablo();
                et.firmaid  = item.firmaid;
                et.firmaadi = item.firmaadi;

                et.C1  = item.C1 = rnd.Next(11);
                et.C2  = item.C2 = rnd.Next(11);
                et.C3  = item.C3 = rnd.Next(11);
                et.C4  = item.C4 = rnd.Next(11);
                et.C5  = item.C5 = rnd.Next(11);
                et.C6  = item.C6 = rnd.Next(11);
                et.C7  = item.C7 = rnd.Next(11);
                et.C8  = item.C8 = rnd.Next(11);
                et.C9  = item.C9 = rnd.Next(11);
                et.C10 = item.C10 = rnd.Next(11);
                et.C11 = item.C11 = rnd.Next(11);
                et.C12 = item.C12 = rnd.Next(11);
                et.C13 = item.C13 = rnd.Next(11);
                et.C14 = item.C14 = rnd.Next(11);
                et.C15 = item.C15 = rnd.Next(11);

                veritabani.SaveChanges();
            }

            return(View());
        }
        public ActionResult FirmaAnket(EgitimTablo tb)
        {
            TestTablo test = new TestTablo();

            kullaniciId = Convert.ToInt32(Session["kullanici"]);
            var kisiId = veritabani.tbl_Kisiler.
                         Where(x => x.kullaniciId == kullaniciId).
                         Select(x => x.kisiId).FirstOrDefault();

            //Firma varmı diye kontrol et firma id alınır
            var firmaVarmi = veritabani.tbl_KatilimciFirma.
                             Join(veritabani.tbl_KatilimciFirmaCalisanlar,
                                  ku => ku.kId,
                                  ki => ki.kId,
                                  (ku, ki) => new { tbl_KatilimciFirma = ku, tbl_KatilimciFirmaCalisanlar = ki }).
                             Where(x => x.tbl_KatilimciFirmaCalisanlar.kisiId == kisiId &&
                                   x.tbl_KatilimciFirma.kId == x.tbl_KatilimciFirmaCalisanlar.kId).
                             Select(x => x.tbl_KatilimciFirma.kId).FirstOrDefault();

            var firmaadi = veritabani.tbl_KatilimciFirma.Where(x => x.kId == firmaVarmi).
                           Select(c => c.kFirmaAdi).FirstOrDefault();

            test.firmaid  = firmaVarmi;
            test.firmaadi = firmaadi;
            test.C1       = tb.C1;
            test.C2       = tb.C2;
            test.C3       = tb.C3;
            test.C4       = tb.C4;
            test.C5       = tb.C5;
            test.C6       = tb.C6;
            test.C7       = tb.C7;
            test.C8       = tb.C8;
            test.C9       = tb.C9;
            test.C10      = tb.C10;
            test.C11      = tb.C11;
            test.C12      = tb.C12;
            test.C13      = tb.C13;
            test.C14      = tb.C14;
            test.C15      = tb.C15;

            veritabani.TestTablo.Add(test);
            veritabani.SaveChanges();

            return(RedirectToAction("FirmaAnket", "Katilimci"));
        }