示例#1
0
        public async Task <JsonResult> GetDetail(Guid id)
        {
            try
            {
                var fault = new FaultRepo().GetById(id);

                var faults   = new FaultRepo().GetAll();
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                var allTechnicians = NewRoleManager().FindByName(IdentityRoles.Technician.ToString()).Users.ToList();
                var user           = await NewUserStore().FindByIdAsync(HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId());

                return(Json(new ResponseData()
                {
                    data = new { fault, user, customer },
                    success = true,
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    success = false,
                    message = $"Bir hata olustu {ex.Message}"
                }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Index(string code)
        {
            var fault      = new FaultRepo().GetAll(x => x.SurveyCode == code).FirstOrDefault();
            var customerId = HttpContext.User.Identity.GetUserId();

            if (customerId == null)
            {
                TempData["Message"] = $"Anketi doldurabilmek için giriş yapmalısınız. ";
                return(RedirectToAction("Index", "Account"));
            }
            else if (fault.CustomerId != customerId)
            {
                TempData["Message"] = $"Bu anket sizin arızanıza tanımlanmamıştır. ";
                return(RedirectToAction("Index", "Account"));
            }

            else if (fault.AnketYapildimi == true)
            {
                TempData["message"] = $"{fault.FaultID} numaralı arıza için daha önceden anket yapılmıştır.";
                return(RedirectToAction("Index", "Account"));
            }
            else
            {
                return(View(fault));
            }
        }
        public async Task <JsonResult> GetDetail(Guid id)
        {
            try
            {
                var fault    = new FaultRepo().GetById(id);
                var faults   = new FaultRepo().GetAll(x => x.FaultID == fault.FaultID);
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                var operatorr = await NewUserStore().FindByIdAsync(fault.OperatorId);

                var teknisyen = await NewUserStore().FindByIdAsync(fault.TechnicianId);

                return(Json(new ResponseData()
                {
                    data = new { fault, customer, operatorr, teknisyen, faults },
                    success = true,
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    success = false,
                    message = $"Bir hata olustu {ex.Message}"
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        public async Task <ActionResult> GetMyRecords()
        {
            var musteriid = HttpContext.User.Identity.GetUserId();
            var data      = new FaultRepo().GetAll(x => x.CustomerId == musteriid).ToList();

            return(View(data));
        }
        public async Task <ActionResult> ConfirmSurvey(Fault model)
        {
            var fault    = new FaultRepo().GetById(model.FaultID);
            var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

            fault.DavranisPuani           = model.DavranisPuani;
            fault.OMNetHakkindakiGorusler = model.OMNetHakkindakiGorusler;
            fault.OMNetHizmetPuanı        = model.OMNetHizmetPuanı;
            fault.TeknisyenDavranisPuani  = model.TeknisyenDavranisPuani;
            fault.TeknisyenBilgiPuani     = model.TeknisyenBilgiPuani;
            fault.AnketYapildimi          = true;

            new FaultRepo().Update(fault);

            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>{customer.Name} {customer.Surname}</b><br>Memnuniyet anketimizi doldurup bizi bilgilendirdiğiniz için teşekkür ederiz.";
            await emailService.SendAsync(new IdentityMessage()
            {
                Body = body, Subject = "Memnuniyet Anketi"
            }, customer.Email);

            return(RedirectToAction("Index", "Account"));
        }
示例#6
0
        public async Task <ActionResult> AssignToTechnician(FaultTrackingViewModel model)
        {
            try
            {
                var teknisyen = await NewUserStore().FindByIdAsync(model.TechnicianID);

                var fault = new FaultRepo().GetById(model.FaultID);
                if (teknisyen != null)
                {
                    fault.TechnicianId    = teknisyen.Id;
                    fault.TechnicianState = TechnicianState.Calısıyor;
                    new FaultRepo().Update(fault);
                    var Log = new FaultLog
                    {
                        TechnicianId         = fault.TechnicianId,
                        CustomerId           = fault.CustomerId,
                        Operation            = $"Arıza {teknisyen.Name} {teknisyen.Surname} isimli teknisyene atandı",
                        FaultId              = fault.FaultID,
                        OperationDescription = fault.FaultDescription
                    };
                    new FaultLogRepo().Insert(Log);
                    TempData["message"] = $"{fault.FaultID} no'lu arıza işlemi {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyene atanmıştır.";
                }
                else
                {
                    throw new Exception("Teknisyen atama işlemi yapılırken bir hata oluştu");
                }
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
            }

            return(View());
        }
        public ActionResult Details(int id)
        {
            var faultRepo = new FaultRepo();
            var Fault     = faultRepo.GetById(id);

            return(View(Fault));
        }
示例#8
0
        // GET: Technician
        public async Task <ActionResult> Index()
        {
            var teknisyen = await NewUserStore().FindByIdAsync(HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId());

            var data = new FaultRepo().GetAll(x => x.TechnicianId == teknisyen.Id && x.FaultState == FaultState.Completed).ToList();

            return(View(data));
        }
示例#9
0
        public async Task <ActionResult> ConfirmFault(Guid id)
        {
            try
            {
                var fault    = new FaultRepo().GetById(id);
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                var technician = await NewUserStore().FindByIdAsync(HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId());

                if (technician != null)
                {
                    fault.haveJob = true;

                    new FaultRepo().Update(fault);
                    var Log = new FaultLog
                    {
                        TechnicianId         = fault.TechnicianId,
                        CustomerId           = fault.CustomerId,
                        Operation            = $"Arıza {technician.Name} {technician.Surname} isimli teknisyene arızayı onayladı",
                        FaultId              = fault.FaultID,
                        OperationDescription = fault.FaultDescription
                    };
                    new FaultLogRepo().Insert(Log);

                    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>{customer.Name} {customer.Surname}</b><br>{technician.Name} {technician.Surname} isimli teknisyen 2 iş günü içerisinde gelecek";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = body, Subject = "Teknisyen atandı"
                    }, customer.Email);
                }

                TempData["Message"] = $"Teknisyen arızayı onaylanmıştır";
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                TempData["Model"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Index",
                    ControllerName = "Operator",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
        }
示例#10
0
        public ActionResult FaultTracking(string id)
        {
            List <Fault> faults = new List <Fault>();

            if (string.IsNullOrEmpty(id))
            {
                faults = new FaultRepo().GetAll().ToList();
            }
            else
            {
                faults = new FaultRepo().GetAll(x => x.OperatorId == id).ToList();
            }

            return(View(faults));
        }
        public ActionResult FaultList(int type = 0)
        {
            ViewBag.Technician = MembershipTools.GetTechnician();
            if (type == 0)
            {
                ViewBag.OperatorID = null;
            }
            else
            {
                ViewBag.OperatorID = System.Web.HttpContext.Current.User.Identity.GetUserId();
            }
            var model = new FaultRepo().GetAll();

            return(View(model));
        }
示例#12
0
        public ActionResult Faults()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            var faults = new FaultRepo().GetAll().Where(x => x.UserID == User.Identity.GetUserId()).ToList();

            if (TempData["Sonuc"] != null)
            {
                ViewBag.Sonuc = TempData["Sonuc"];
                TempData.Remove("Sonuc");
            }

            return(View(faults));
        }
示例#13
0
        public ActionResult Delete(int id)
        {
            var faultrepo = new FaultRepo();
            var fault     = faultrepo.GetById(id);

            try
            {
                faultrepo.Delete(fault);
            }
            catch (Exception ex)
            {
                TempData["Sonuc"] = "Arıza Silinemedi" + ex.Message;
                return(RedirectToAction("Faults"));
            }
            TempData["Sonuc"] = "Arıza Silindi";
            return(RedirectToAction("Faults"));
        }
示例#14
0
        public async Task <JsonResult> GetDetail(Guid id)
        {
            List <User> users = new List <User>();
            int         sayac = 0;

            try
            {
                var fault    = new FaultRepo().GetById(id);
                var faults   = new FaultRepo().GetAll();
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                var allTechnicians = NewRoleManager().FindByName(IdentityRoles.Technician.ToString()).Users.ToList();
                var user           = await NewUserStore().FindByIdAsync(HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId());

                foreach (var item in allTechnicians)
                {
                    var calisiyorMu = new FaultRepo().GetAll().FirstOrDefault(x => x.TechnicianId == item.UserId && x.TechnicianState == TechnicianState.Calısıyor);

                    if (calisiyorMu == null)
                    {
                        var User = NewUserManager().FindById(item.UserId);
                        users.Add(User);
                    }
                }



                return(Json(new ResponseData()
                {
                    data = new { fault, user, customer, users },
                    success = true,
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    success = false,
                    message = $"Bir hata olustu {ex.Message}"
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#15
0
        // GET: Operator
        public ActionResult Index()
        {
            var data = new FaultRepo().GetAll(x => x.AssignedOperator == false).Select(x => new FaultViewModel()
            {
                Adress           = x.Adress,
                FaultPath        = x.FaultPath,
                FaultDescription = x.FaultDescription,
                AssignedOperator = x.AssignedOperator,
                CustomerId       = x.CustomerId,
                FaultID          = x.FaultID,
                FaultNotifyDate  = x.FaultNotifyDate,
                FaultResultDate  = x.FaultResultDate,
                InvoicePath      = x.InvoicePath,
                FaultState       = x.FaultState,
                OperatorId       = x.OperatorId,
                TechnicianId     = x.TechnicianId,
            }).ToList();

            return(View(data));
        }
        public string UpdateFault(string latlng, string technician, string id, string address, string title, string description)
        {
            var latlngArray = latlng.Split(',');
            var faultrepo   = new FaultRepo();
            var fault       = faultrepo.GetById(Convert.ToInt32(id));

            fault.TechnicianID = technician;
            fault.lat          = latlngArray[0];
            fault.lng          = latlngArray[1];
            fault.Address      = address;
            fault.Description  = description;
            fault.OperatorID   = System.Web.HttpContext.Current.User.Identity.GetUserId();
            fault.Title        = title;
            try
            {
                faultrepo.Update();
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("ok");
        }
示例#17
0
        public async Task <ActionResult> SendSurvey(Guid id)
        {
            try
            {
                var fault    = new FaultRepo().GetById(id);
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                fault.SurveyCode = StringHelper.GetCode();
                new FaultRepo().Update(fault);

                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>{customer.Name} {customer.Surname}</b><br>Sunmuş olduğumuz servis hizmeti için kısa bir memnuniyet anketi doldurmanızı talep ediyoruz.Verilen linke tıklayarak anketimizi doldurabilirsiniz.İlginize teşekkürler..<br> <a href='{SiteUrl}/survey/index?code={fault.SurveyCode}' >Anket Linki </a> ";
                await emailService.SendAsync(new IdentityMessage()
                {
                    Body = body, Subject = "Sitemize Hoşgeldiniz"
                }, customer.Email);

                TempData["message"] = $"{customer.Name} {customer.Surname} isimli müşterimize memnuniyet anketi gönderilmiştir.";

                return(RedirectToAction("Index", "Operator"));
            }
            catch (Exception ex)
            {
                TempData["Model"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Index",
                    ControllerName = "Operator",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
        }
示例#18
0
        public ActionResult Edit(int id)
        {
            var model = new FaultRepo().GetById(id);

            return(View(model));
        }
示例#19
0
        public async Task <ActionResult> FaultCreate(FaultViewModel model)
        {
            //o anki sistemdeki kullanıcının idsini verir.

            var MusteriId = HttpContext.User.Identity.GetUserId();


            //if (!ModelState.IsValid)
            //{
            //    //Gelen model valid degiilse bu sayfaya yönlendirilip hatalar gösterilicek.
            //    return RedirectToAction("Index", "Musteri", model);
            //}


            try
            {
                #region ArızaResimİşlemi
                if (model.PostedFileFault != null &&
                    model.PostedFileFault.ContentLength > 0)
                {
                    var    file     = model.PostedFileFault;
                    string fileName = Path.GetFileNameWithoutExtension(file.FileName);
                    string extName  = Path.GetExtension(file.FileName);
                    fileName  = StringHelper.UrlFormatConverter(fileName);
                    fileName += StringHelper.GetCode();
                    var klasoryolu = Server.MapPath("~/Ariza/");
                    var dosyayolu  = Server.MapPath("~/Ariza/") + fileName + extName;

                    if (!Directory.Exists(klasoryolu))
                    {
                        Directory.CreateDirectory(klasoryolu);
                    }
                    file.SaveAs(dosyayolu);

                    WebImage img = new WebImage(dosyayolu);
                    img.Resize(250, 250, false);
                    img.AddTextWatermark("FİTech");
                    img.Save(dosyayolu);
                    var oldPath = model.FaultPath;
                    model.FaultPath = "/Ariza/" + fileName + extName;

                    System.IO.File.Delete(Server.MapPath(oldPath));
                }


                #endregion

                #region FaturaResimİşlemleri
                if (model.PostedFileInvoice != null &&
                    model.PostedFileInvoice.ContentLength > 0)
                {
                    var    file     = model.PostedFileInvoice;
                    string fileName = Path.GetFileNameWithoutExtension(file.FileName);
                    string extName  = Path.GetExtension(file.FileName);
                    fileName  = StringHelper.UrlFormatConverter(fileName);
                    fileName += StringHelper.GetCode();
                    var klasoryolu = Server.MapPath("~/Fatura/");
                    var dosyayolu  = Server.MapPath("~/Fatura/") + fileName + extName;

                    if (!Directory.Exists(klasoryolu))
                    {
                        Directory.CreateDirectory(klasoryolu);
                    }
                    file.SaveAs(dosyayolu);

                    WebImage img = new WebImage(dosyayolu);
                    img.Resize(250, 250, false);
                    img.AddTextWatermark("FİTech");
                    img.Save(dosyayolu);
                    var oldPath = model.InvoicePath;
                    model.InvoicePath = "/Fatura/" + fileName + extName;

                    System.IO.File.Delete(Server.MapPath(oldPath));
                }


                #endregion

                var data = new Fault
                {
                    CustomerId       = MusteriId,
                    FaultPath        = model.FaultPath,
                    InvoicePath      = model.InvoicePath,
                    Adress           = model.Adress,
                    FaultDescription = model.FaultDescription,
                    AssignedOperator = false,
                    FaultState       = FaultState.Uncompleted,
                    FaultID          = model.FaultID,
                };
                new FaultRepo().Insert(data);
                var Log = new FaultLog
                {
                    TechnicianId         = data.TechnicianId,
                    CustomerId           = data.CustomerId,
                    Operation            = "Arıza kaydı oluşturuldu",
                    FaultId              = data.FaultID,
                    OperationDescription = data.FaultDescription
                };
                new FaultLogRepo().Insert(Log);

                var fault    = new FaultRepo().GetById(data.FaultID);
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                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>{data.FaultID} nolu Arıza kaydınız alınmıştır";
                await emailService.SendAsync(new IdentityMessage()
                {
                    Body = body, Subject = "Arıza Kaydı"
                }, customer.Email);

                TempData["Message"] = $"{model.FaultID} no'lu kayıt başarıyla eklenmiştir";
                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException ex)
            {
                TempData["Model"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu: {EntityHelpers.ValidationMessage(ex)}",
                    ActionName     = "Index",
                    ControllerName = "Musteri",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
            catch (Exception ex)
            {
                TempData["Model"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu: {ex.Message}",
                    ActionName     = "Index",
                    ControllerName = "Musteri",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
        }
示例#20
0
        public async Task <ActionResult> FaultFinish(FaultFinishViewModel model)
        {
            try
            {
                var teknisyen = await NewUserStore()
                                .FindByIdAsync(HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId());

                var fault     = new FaultRepo().GetById(model.FaultID);
                var operatorr = await NewUserStore().FindByIdAsync(fault.OperatorId);

                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                if (teknisyen != null && model.faultState == FaultState.Completed)
                {
                    fault.FaultState            = model.faultState;
                    fault.FaultResultDate       = DateTime.Now;;
                    fault.TechnicianDescription = model.TechnicianDescription;
                    fault.haveJob         = false;
                    fault.TechnicianState = TechnicianState.Bosta;
                    new FaultRepo().Update(fault);
                    var Log = new FaultLog
                    {
                        TechnicianId         = fault.TechnicianId,
                        CustomerId           = fault.CustomerId,
                        Operation            = fault.FaultState.ToString(),
                        FaultId              = fault.FaultID,
                        OperationDescription = fault.FaultDescription
                    };
                    new FaultLogRepo().Insert(Log);
                    TempData["message"] =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilmiştir.";
                    string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                     (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);

                    var emailService = new EmailService();
                    var body         =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilmiştir.";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = body, Subject = "İş Durumu"
                    },
                                                 operatorr.Email);

                    var bodyy =
                        $"{fault.FaultID} no'lu arızanız {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilmiştir.<br>Bizi tercih ettiğiniz için teşekkür ederiz";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = bodyy, Subject = "İş Durumu"
                    },
                                                 customer.Email);
                }
                else if (teknisyen != null && model.faultState == FaultState.Pending)
                {
                    fault.FaultState = model.faultState;
                    new FaultRepo().Update(fault);
                    TempData["message"] =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilememiştir.";
                    string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                     (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);
                    var emailService = new EmailService();
                    var body         =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilememiştir.<br>Açıklama:{model.TechnicianDescription} ";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = body, Subject = "İş Durumu"
                    },
                                                 operatorr.Email);
                }
                else
                {
                    throw new Exception("İşlemi bitirirken hata oluştu");
                }
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
            }

            return(RedirectToAction("Index", "Technician", model));
        }
        public ActionResult AdminPanel()
        {
            var data = new FaultRepo().GetAll();

            return(View(data));
        }
示例#22
0
        public ActionResult FaultList()
        {
            var model = new FaultRepo().GetAll().Where(x => x.TechnicianID == MembershipTools.GetUser().Id).ToList();

            return(View(model));
        }
示例#23
0
        public ActionResult FaultTracking(string id)
        {
            var data = new FaultRepo().GetAll(x => x.TechnicianId == id && (x.FaultState == FaultState.Uncompleted || x.FaultState == FaultState.Pending)).ToList();

            return(View(data));
        }