public ActionResult Anket(int code)
 {
     try
     {
         var anketRepo = new AnketRepository();
         var anket     = anketRepo.GetById(code);
         if (anket == null)
         {
             return(RedirectToAction("Index", "Home"));
         }
         var data = Mapper.Map <Anket, AnketViewModel>(anket);
         return(View(data));
     }
     catch (Exception ex)
     {
         TempData["Message2"] = new ErrorViewModel()
         {
             Text           = $"Bir hata oluştu {ex.Message}",
             ActionName     = "Anket",
             ControllerName = "Musteri",
             ErrorCode      = 500
         };
         return(RedirectToAction("Error", "Home"));
     }
 }
Example #2
0
        public JsonResult Rapor1()
        {
            var anketRepo = new AnketRepository();
            var soru1     = anketRepo.GetAll().Select(x => x.Soru1).Sum() / anketRepo.GetAll().Select(x => x.Soru1).Count();
            var soru2     = anketRepo.GetAll().Select(x => x.Soru2).Sum() / anketRepo.GetAll().Select(x => x.Soru2).Count();
            var soru3     = anketRepo.GetAll().Select(x => x.Soru3).Sum() / anketRepo.GetAll().Select(x => x.Soru3).Count();
            var soru4     = anketRepo.GetAll().Select(x => x.Soru4).Sum() / anketRepo.GetAll().Select(x => x.Soru4).Count();
            var soru5     = anketRepo.GetAll().Select(x => x.Soru5).Sum() / anketRepo.GetAll().Select(x => x.Soru5).Count();


            var data = new List <ReportData>();

            data.Add(new ReportData()
            {
                Soru  = "Firma Memnuniyeti",
                Deger = soru1
            });
            data.Add(new ReportData()
            {
                Soru  = "Nezaket",
                Deger = soru2
            });
            data.Add(new ReportData()
            {
                Soru  = "Teknik Bilgi ve Yeterlilik",
                Deger = soru3
            });
            data.Add(new ReportData()
            {
                Soru  = "Hız",
                Deger = soru4
            });
            data.Add(new ReportData()
            {
                Soru  = "Fiyat",
                Deger = soru5
            });
            return(Json(new ResponseData()
            {
                message = $"{data.Count} adet kayıt bulundu",
                success = true,
                data = data
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Anket(AnketViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Hata Oluştu.");
                return(RedirectToAction("Anket", "Musteri", model));
            }
            try
            {
                var anketRepo = new AnketRepository();
                var anket     = anketRepo.GetById(model.AnketId);
                if (anket == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                anket.Soru1 = model.Soru1;
                anket.Soru2 = model.Soru2;
                anket.Soru3 = model.Soru3;
                anket.Soru4 = model.Soru4;
                anket.Soru5 = model.Soru5;
                anket.Soru6 = model.Soru6;
                anketRepo.Update(anket);

                TempData["Message2"] = "Anket tamamlandı.";
                return(RedirectToAction("Index", "Musteri"));
            }
            catch (Exception ex)
            {
                TempData["Message2"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Anket",
                    ControllerName = "Musteri",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
        }
Example #4
0
        public JsonResult Rapor4()
        {
            var arizaRepo = new ArizaRepository().GetAll();
            var userRepo  = NewUserManager().Users.ToList();
            var anketRepo = new AnketRepository().GetAll();

            var teknisyenSorgu = from ariza in arizaRepo
                                 join teknisyen in userRepo on ariza.TeknisyenId equals teknisyen.Id
                                 join anket in anketRepo on ariza.AnketId equals anket.Id
                                 where teknisyen.Id == ariza.TeknisyenId & anket.Id == ariza.AnketId
                                 group new
            {
                ariza,
                teknisyen
            }
            by new
            {
                teknisyen.Name,
                teknisyen.Surname
            }
            into gp
                select new
            {
                isim   = gp.Key.Name + " " + gp.Key.Surname,
                toplam = gp.Average(x => x.ariza.Anket.Soru6)
            };

            var data = teknisyenSorgu.ToList();

            return(Json(new ResponseData()
            {
                message = $"{data.Count} adet kayıt bulundu",
                success = true,
                data = data
            }, JsonRequestBehavior.AllowGet));
        }
Example #5
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
                }));
            }
        }