public IActionResult Soru(Anket anket)
 {
     try
     {
         Sonuc sonuc = new Sonuc()
         {
             SoruID = anket.ID
         };
         if (anket.A)
         {
             sonuc.Cevap = 1;
         }
         if (anket.B)
         {
             sonuc.Cevap = 2;
         }
         if (anket.C)
         {
             sonuc.Cevap = 3;
         }
         if (anket.D)
         {
             sonuc.Cevap = 4;
         }
         _context.Sonuc.Add(sonuc);
         _context.SaveChanges();
     }
     catch (Exception exp)
     {
         ViewBag.Hata = exp.Message;
     }
     return(RedirectToAction(nameof(Soru)));
 }
Ejemplo n.º 2
0
        private static void AnketSonucuKaydet(byte ButonNo, byte Adres)
        {
            //anket sonucunu kaydet.
            Anket an = new Anket();

            an.Secim      = ButonNo;
            an.TerminalId = Adres;
            an.Insert();
        }
        /// <summary>Deletes the specified identifier.</summary>
        /// <param name="id">The identifier.</param>
        public void Delete(int id)
        {
            Anket anket = db.Ankets.Find(id);

            if (anket != null)
            {
                db.Ankets.Remove(anket);
            }
        }
Ejemplo n.º 4
0
        public virtual void AnketGüncelle(Anket anket)
        {
            if (anket == null)
            {
                throw new ArgumentNullException("anket");
            }

            _anketDepo.Güncelle(anket);
            _olayYayınlayıcı.OlayGüncellendi(anket);
        }
Ejemplo n.º 5
0
        public virtual void AnketSil(Anket anket)
        {
            if (anket == null)
            {
                throw new ArgumentNullException("anket");
            }

            _anketDepo.Sil(anket);
            _olayYayınlayıcı.OlaySilindi(anket);
        }
 public IActionResult Apply(Anket anket)
 {
     if (ModelState.IsValid)
     {
         Repository.AddAnket(anket);
         return(View("Thanks", anket));
     }
     else
     {
         return(View(anket));
     }
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> SubmitAnket(Anket anket)
        {
            OrderItems order    = new OrderItems(anket.Adress, anket.Name + ":" + anket.Email, anket.Money, anket.Adress);
            int        BookCost = 2000;
            int        GameCost = 3000;

            if (anket.Book != 0 && anket.Computer != 0)
            {
                decimal partBook      = anket.Book / (anket.Book + anket.Computer);
                decimal partComp      = anket.Computer / (anket.Book + anket.Computer);
                int     countAllItems = Convert.ToInt32(Convert.ToInt32(anket.Money) / (partBook * BookCost + partComp * GameCost));

                int    CountBook  = Convert.ToInt32(partBook * countAllItems);
                int    CountGame  = Convert.ToInt32(partComp * countAllItems);
                string OrderItems = "Harry Potter=" + CountBook + "Witcher 3=" + CountGame;
                order.productsInBox = OrderItems;
                //api / OrderItems

                var values = new JObject();
                values.Add("Adress", order.Adress);
                values.Add("Cost", order.Cost);
                values.Add("DeliveryInfo", order.DeliveryInfo);
                values.Add("ProductsInBox", order.productsInBox);
                values.Add("UserInfo", order.UserInfo);

                string usr = HttpContext.Session.GetString("Login");
                usr = usr != null ? usr : "";

                try
                {
                    var result = await QueryClient.SendQueryToService(HttpMethod.Post, Linker.Orders, "/api/OrderItems", null, values);

                    OrderItems resultUser = JsonConvert.DeserializeObject <OrderItems>(result);

                    StatisticSender.SendStatistic("Home", DateTime.Now, "Registration", Request.HttpContext.Connection.RemoteIpAddress.ToString(), true, usr);
                    return(View("SuccessSub", resultUser));
                }
                catch
                {
                    StatisticSender.SendStatistic("Home", DateTime.Now, "Registration", Request.HttpContext.Connection.RemoteIpAddress.ToString(), false, usr);
                    return(View("Error", "Cannot create order"));
                }
            }
            else
            {
                return(View("Index"));
            }
        }
        public async Task <ActionResult> ArizaAnket(int?id, AnketViewModel model)

        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var ariza = new ArizaRepo().GetByID(id.Value);

            if (ariza == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Anket yeniAnket = new Anket()
            {
                Aciklama    = model.Aciklama,
                ArizaID     = ariza.ID,
                KullaniciID = ariza.KullaniciID,
                Puan        = model.Puan,
                TeknikerID  = ariza.TeknikerID
            };

            new AnketRepo().Insert(yeniAnket);
            string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                             (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);
            var roleManager = MembershipTools.NewRoleManager();
            var users       = roleManager.FindByName("Admin").Users;

            var           userManager = MembershipTools.NewUserManager();
            List <string> mailler     = new List <string>();

            foreach (var item in users)
            {
                mailler.Add(userManager.FindById(item.UserId).Email);
            }

            foreach (var mail in mailler)
            {
                await SiteSettings.SendMail(new MailModel
                {
                    Subject = "Yeni Anket Bildirimi",
                    Message = $"Sayın Operatör,<br/>Sitenize bir anket eklendi, Lütfen gereken işlemleri gerçekleştirin.<br/><a href='{SiteUrl}/Admin/AnketDetay/{yeniAnket.ID}'>Şimdi Bak</a><p>İyi Çalışmalar<br/>Sitenin Nöbetçisi</p>",
                    To      = mail
                });
            }
            return(RedirectToAction("Index", "Home"));
        }
 public IActionResult Ekle(Anket anket)
 {
     try
     {
         if (ModelState.IsValid)
         {
             anket.Tarih = DateTime.Now;
             _context.Anket.Add(anket);
             _context.SaveChanges();
             return(RedirectToAction(nameof(Soru)));
         }
     }
     catch (Exception exp)
     {
         ViewBag.Hata = exp.Message;
     }
     return(View(anket));
 }
Ejemplo n.º 10
0
        // Save new anket in db.
        public void AddNewAnket(string Name, string Gender, string[] Operator, string UseCodeOperatop)
        {
            string oper = "";

            foreach (var s in Operator)
            {
                oper += s;
                oper += " , ";
            }
            Anket anket = new Anket();

            anket.Gender          = Gender;
            anket.Name            = Name;
            anket.Operator        = oper;
            anket.UseCodeOperatop = UseCodeOperatop;
            Database.Ankets.Create(anket);
            Database.Ankets.Save();
        }
Ejemplo n.º 11
0
        public ActionResult AnketEkle(AnketViewModel model)
        {
            var anketrepo = new AnketRepo();
            var sorurepo  = new SoruRepo();
            var yeniAnket = new Anket()
            {
                AnketIsmi = model.anketadi
            };

            anketrepo.Insert(yeniAnket);

            model.sorulistesi.ForEach(x =>
            {
                sorurepo.Insert(new Soru()
                {
                    SoruMetni = x.SoruMetni,
                    AnketID   = yeniAnket.ID,
                });
            });

            return(View());
        }
Ejemplo n.º 12
0
 public static void anketEkle(Anket sA)
 {
     anketler.Add(sA);
 }
 /// <summary>Updates the specified entity.</summary>
 /// <param name="entity">The entity.</param>
 public void Update(Anket entity)
 {
     db.Entry(entity).State = EntityState.Modified;
 }
 /// <summary>Creates the specified entity.</summary>
 /// <param name="entity">The entity.</param>
 public void Create(Anket entity)
 {
     db.Ankets.Add(entity);
 }
Ejemplo n.º 15
0
        public async Task <JsonResult> IslemTamam(int id)
        {
            try
            {
                var arizaRepo = new ArizaRepository();
                var ariza     = arizaRepo.GetAll().FirstOrDefault(x => x.Id == id);
                var userStore = NewUserStore();
                var teknisyen = await userStore.FindByIdAsync(ariza.TeknisyenId);

                var musteri = await userStore.FindByIdAsync(ariza.MusteriId);

                if (teknisyen == null)
                {
                    return(Json(new ResponseData()
                    {
                        message = "Kullanıcı bulunamadı",
                        success = false
                    }));
                }

                ariza.ArizaBitisTarihi    = DateTime.Now;
                teknisyen.TeknisyenDurumu = TeknisyenDurumu.Bosta;
                await userStore.UpdateAsync(teknisyen);

                userStore.Context.SaveChanges();
                ariza.ArizaYapildiMi = true;

                var arizaLogRepo = new ArizaLogRepository();
                var log          = new ArizaLog()
                {
                    ArizaId  = ariza.Id,
                    Aciklama = "Arıza çözümlenmiştir.",
                    Zaman    = ariza.ArizaBitisTarihi.Value
                };
                arizaLogRepo.Insert(log);
                //ariza.ArizaLoglar.Add(log);
                ariza.Teknisyen.TeknisyenDurumu = teknisyen.TeknisyenDurumu;
                arizaRepo.Update(ariza);

                var anket     = new Anket();
                var anketRepo = new AnketRepository();
                anketRepo.Insert(anket);
                ariza.AnketId = anket.Id;
                arizaRepo.Update(ariza);


                string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                 (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);

                var emailService = new EmailService();
                var body         = $"Merhaba <b>{musteri.Name} {musteri.Surname}</b><br><br> <a href='{SiteUrl}/musteri/anket?code={ariza.AnketId}' >Anket Linki </a> ";
                await emailService.SendAsync(new IdentityMessage()
                {
                    Body = body, Subject = "Memnuniyet Anketi"
                }, musteri.Email);

                var data = new ArizaViewModel
                {
                    ArizaYapildiMi       = ariza.ArizaYapildiMi,
                    Id                   = ariza.Id,
                    ArizaBitisTarihi     = ariza.ArizaBitisTarihi ?? DateTime.Now,
                    TeknisyenDurumu      = ariza.Teknisyen.TeknisyenDurumu,
                    Aciklama             = ariza.Aciklama,
                    Adres                = ariza.Adres,
                    MarkaAdi             = ariza.MarkaAdi,
                    ModelAdi             = ariza.ModelAdi,
                    MusteriId            = ariza.MusteriId,
                    MusteriAdi           = ariza.Musteri.Name + " " + ariza.Musteri.Surname,
                    ArizaOlusturmaTarihi = ariza.ArizaOlusturmaTarihi,
                    ArizaOnaylandiMi     = ariza.ArizaOnaylandiMi,
                    TeknisyenId          = ariza.TeknisyenId,
                };


                return(Json(new ResponseData()
                {
                    message = "İşlem başarılı",
                    success = true,
                    data = data
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    message = $"Bir hata oluştu: {ex.Message}",
                    success = false
                }));
            }
        }
Ejemplo n.º 16
0
        public void Kaydet(List <String> gSoru)
        {
            Anket   anket = new Anket();
            Sorular soru  = new Sorular();

            using (AnketEntities db = new AnketEntities())
            {
                int counter = 0;
                anket.anketAdi = gSoru[0].ToString();
                anket.anketTur = gSoru[1].ToString();
                DateTime bugun = DateTime.Now;
                anket.oTarih           = bugun;
                anket.gTarih           = bugun.AddDays(Convert.ToInt32(gSoru[2]));
                anket.sinir            = Convert.ToInt32(gSoru[3]);
                anket.gorunurluk       = Convert.ToInt32(gSoru[4]);
                anket.anketKullaniciId = Convert.ToInt32(Session["kullanici"].ToString());
                foreach (var text in gSoru)
                {
                    if (text == "1$#$#" || text == "2$#$#" || text == "3$#$#")
                    {
                        counter++;
                    }
                }
                anket.anketSoruSayisi = counter;
                db.Anket.Add(anket);
                db.SaveChanges();
            }

            List <Soru> sorular = new List <Soru>();
            int         yeni    = 0;

            for (int i = 5; i < gSoru.Count; i++)
            {
                if (gSoru[i] == "1$#$#" || gSoru[i] == "2$#$#" || gSoru[i] == "3$#$#")
                {
                    using (AnketEntities db = new AnketEntities())
                    {
                        var soruC = db.Sorular.Where(x => x.soruId == soru.soruId).FirstOrDefault();
                        soruC.secenekSayisi = db.Secenekler.Where(x => x.soruId == soru.soruId).ToList().Count;
                        if (gSoru[i] == "1$#$#")
                        {
                            soruC.soruTipId = 1;
                        }
                        else if (gSoru[i] == "2$#$#")
                        {
                            soruC.soruTipId = 2;
                        }
                        else
                        {
                            soruC.soruTipId = 3;
                        }
                        db.SaveChanges();
                        soru = new Sorular();
                    }
                    yeni = 0;
                }
                else
                {
                    if (yeni == 0)
                    {
                        using (AnketEntities db = new AnketEntities())
                        {
                            soru.anketId   = anket.anketId;
                            soru.soruMetni = gSoru[i].ToString();

                            soru.soruTipId = 3;//çek
                            db.Sorular.Add(soru);
                            db.SaveChanges();
                        }
                        yeni++;
                    }

                    else
                    {
                        using (AnketEntities db = new AnketEntities())
                        {
                            int        sId = soru.soruId; //int double ile değişecek vt'da da
                            Secenekler secenek;
                            secenek = new Secenekler();
                            secenek.secenekMetni = gSoru[i];
                            secenek.soruId       = sId;
                            db.Secenekler.Add(secenek);
                            db.SaveChanges();
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public ActionResult Rapor(int id)
        {
            List <Sonuc> sonuclar = new List <Sonuc>();

            using (AnketEntities db = new AnketEntities())
            {
                Anket          anket   = db.Anket.Where(x => x.anketId == id).FirstOrDefault();
                List <Sorular> sorular = db.Sorular.Where(x => x.anketId == id).ToList();


                foreach (var soru in sorular)
                {
                    Sonuc             sonuc      = new Sonuc();
                    List <Secenekler> secenekler = new List <Secenekler>();
                    sonuc.soruMetni = soru.soruMetni;
                    sonuc.tip       = soru.soruTipId;
                    sonuc.count     = db.Cevaplar.Where(x => x.soruId == soru.soruId).ToList().Count;//Yanlış olabilir
                    sonuc.soruId    = soru.soruId;
                    if (sonuc.tip != 3)
                    {
                        int counter = 0;
                        secenekler       = db.Secenekler.Where(x => x.soruId == soru.soruId).ToList();
                        sonuc.secenekler = new List <Secenek>();
                        int i = 0;
                        foreach (var secenek in secenekler)
                        {
                            Secenek sec = new Secenek();
                            sonuc.cevap       = new string[secenekler.Count];
                            sonuc.cevapSayisi = new int[secenekler.Count];
                            sec.cevapMetin    = secenek.secenekMetni;
                            sonuc.cevap[i]    = secenek.secenekMetni;
                            if (soru.soruTipId == 2)
                            {
                                sec.cevaplamaSayisi = db.Cevaplar.Where(x => x.soruId == soru.soruId).Where(y => y.cevap == (counter.ToString())).ToList().Count;
                            }
                            else
                            {
                                int             count = 0;
                                List <Cevaplar> cvp   = db.Cevaplar.Where(x => x.soruId == soru.soruId).ToList();
                                foreach (var c in cvp)
                                {
                                    String[] yanit = c.cevap.Split(',');
                                    foreach (var y in yanit)
                                    {
                                        if (y == (counter.ToString()))
                                        {
                                            count++;
                                        }
                                    }
                                }
                                sec.cevaplamaSayisi  = count;
                                sonuc.cevapSayisi[i] = count;
                            }


                            counter++;
                            sonuc.secenekler.Add(sec);
                            i++;
                        }
                    }
                    else
                    {
                        List <Cevaplar> cvp = db.Cevaplar.Where(x => x.soruId == soru.soruId).ToList();
                        sonuc.secenekler = new List <Secenek>();
                        foreach (var yanit in cvp)
                        {
                            Secenek sec1 = new Secenek();
                            sec1.cevaplamaSayisi = db.Cevaplar.Where(x => x.soruId == soru.soruId).ToList().Count;
                            sec1.cevapMetin      = yanit.cevap;
                            sonuc.secenekler.Add(sec1);
                        }
                    }
                    sonuclar.Add(sonuc);
                }
            }
            return(View(sonuclar));
        }
        /// <summary>Creates the schema anket for seed.</summary>
        /// <returns>
        ///   Anket<br />
        /// </returns>
        Anket CreateSchemaAnket()
        {
            var nAnket = new Anket {
                Title = "Main", Questions = new List <AnketQuestion>()
            };

            var qFirstName = new AnketQuestion {
                Name = "Name", Description = "First Name", Anket = nAnket, QType = QuestionType.T
            };

            contextDB.AnketQuestions.Add(qFirstName);
            nAnket.Questions.Add(qFirstName);

            var qSecondName = new AnketQuestion {
                Name = "Surname", Description = "Second Name", Anket = nAnket, QType = QuestionType.T
            };

            contextDB.AnketQuestions.Add(qSecondName);
            nAnket.Questions.Add(qSecondName);

            var qBDate = new AnketQuestion {
                Name = "Birthday", Description = "Birthday Date", Anket = nAnket, QType = QuestionType.T
            };

            contextDB.AnketQuestions.Add(qBDate);
            nAnket.Questions.Add(qBDate);

            var oftenVisitChoices = new List <AnketChoice>();
            var oftenVisit        = new List <string>()
            {
                "Daily", "Weekly", "Monthly", "Less than once a month", "Never"
            };
            var qOftenVisit = new AnketQuestion
            {
                Name         = "OftenVisit",
                Description  = "On an average how often do you visit public libraries?",
                Anket        = nAnket,
                QType        = QuestionType.S,
                AnketChoices = oftenVisitChoices
            };

            foreach (var item in oftenVisit)
            {
                oftenVisitChoices.Add(new AnketChoice {
                    Name = item, Question = qOftenVisit
                });
            }
            contextDB.AnketChoices.AddRange(oftenVisitChoices);
            contextDB.AnketQuestions.Add(qOftenVisit);
            nAnket.Questions.Add(qOftenVisit);


            var findServiceChoices = new List <AnketChoice>();
            var findService        = new List <string>()
            {
                "Library website", "Social Media Platform", "Newspaper", "Newsletter", "Flyers", "Other"
            };
            var qFindService = new AnketQuestion
            {
                Name         = "FindService",
                Description  = "How did you find out about the library services? Select all that is applicable",
                Anket        = nAnket,
                QType        = QuestionType.M,
                AnketChoices = findServiceChoices
            };

            foreach (var item in findService)
            {
                findServiceChoices.Add(new AnketChoice {
                    Name = item, Question = qFindService
                });
            }
            contextDB.AnketChoices.AddRange(findServiceChoices);
            contextDB.AnketQuestions.Add(qFindService);
            nAnket.Questions.Add(qFindService);

            var eduChoices = new List <AnketChoice>();
            var edu        = new List <string>()
            {
                "High school", "Some college", "Trade/vocational/technical", "Associates", "Bachelors", "Masters", "Professional", "Doctorate"
            };
            var qEdu = new AnketQuestion
            {
                Name         = "Edu",
                Description  = "Please select your highest level of educational qualification",
                Anket        = nAnket,
                QType        = QuestionType.S,
                AnketChoices = eduChoices
            };

            foreach (var item in edu)
            {
                eduChoices.Add(new AnketChoice {
                    Name = item, Question = qEdu
                });
            }
            contextDB.AnketChoices.AddRange(eduChoices);
            contextDB.AnketQuestions.Add(qEdu);
            nAnket.Questions.Add(qEdu);


            var employmentStatusChoices = new List <AnketChoice>();
            var employmentStatus        = new List <string>()
            {
                "Full-time employment", "Part-time employment", "Unemployed", "Self-employed", "Home-maker", "Student", "Retired", "Military"
            };
            var qEmploymentStatus = new AnketQuestion
            {
                Name         = "EmploymentStatus",
                Description  = "What is your employment status?",
                Anket        = nAnket,
                QType        = QuestionType.S,
                AnketChoices = employmentStatusChoices
            };

            foreach (var item in employmentStatus)
            {
                employmentStatusChoices.Add(new AnketChoice {
                    Name = item, Question = qEmploymentStatus
                });
            }
            contextDB.AnketChoices.AddRange(employmentStatusChoices);
            contextDB.AnketQuestions.Add(qEmploymentStatus);
            nAnket.Questions.Add(qEmploymentStatus);

            return(nAnket);
        }