public static string GetTechPoint(string techId)
        {
            var tech = NewUserManager().FindById(techId);

            if (tech == null)
            {
                return("0");
            }
            var issues = new IssueRepo().GetAll(x => x.TechnicianId == techId);

            if (issues == null)
            {
                return("0");
            }
            var isDoneIssues = new List <Issue>();

            foreach (var issue in issues)
            {
                var survey = new SurveyRepo().GetById(issue.SurveyId);
                if (survey.IsDone)
                {
                    isDoneIssues.Add(issue);
                }
            }

            var count = 0.0;

            foreach (var item in isDoneIssues)
            {
                var survey = new SurveyRepo().GetById(item.SurveyId);
                count += survey.TechPoint;
            }

            return(isDoneIssues.Count != 0 ? $"{count / isDoneIssues.Count}" : "0");
        }
Exemple #2
0
        public ActionResult Details(string id)
        {
            var issue = new IssueRepo().GetById(id);
            var data  = Mapper.Map <Issue, IssueVM>(issue);

            return(View(data));
        }
Exemple #3
0
        public async Task <ActionResult> FinishJob(IssueVM model)
        {
            try
            {
                var issueRepo = new IssueRepo();
                var issue     = issueRepo.GetById(model.IssueId);
                if (issue == null)
                {
                    TempData["Message2"] = "Arıza kaydı bulunamadi.";
                    return(RedirectToAction("Index", "Technician"));
                }

                issue.IssueState = IssueStates.Tamamlandı;
                issue.ClosedDate = DateTime.Now;
                issueRepo.Update(issue);
                TempData["Message"] = $"{issue.Description} adlı iş tamamlandı.";

                var survey     = new Survey();
                var surveyRepo = new SurveyRepo();
                surveyRepo.Insert(survey);
                issue.SurveyId = survey.Id;
                issueRepo.Update(issue);

                var user = await NewUserStore().FindByIdAsync(issue.CustomerId);

                var usernamesurname = GetNameSurname(issue.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>{usernamesurname}</b><br>{issue.Description} adlı arıza kaydınız kapanmıştır.<br>Değerlendirmeniz için aşağıda linki bulunan anketi doldurmanızı rica ederiz.<br> <a href='{siteUrl}/issue/survey?code={issue.SurveyId}' >Anket Linki </a> ";
                await emailService.SendAsync(new IdentityMessage()
                {
                    Body = body, Subject = "Değerlendirme Anketi"
                }, user.Email);

                var issueLog = new IssueLog()
                {
                    IssueId     = issue.Id,
                    Description = "İş tamamlandı.",
                    FromWhom    = "Teknisyen"
                };
                new IssueLogRepo().Insert(issueLog);

                return(RedirectToAction("Index", "Technician"));
            }
            catch (Exception ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu. {ex.Message}",
                    ActionName     = "FinishJob",
                    ControllerName = "Technician",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }
Exemple #4
0
        public ActionResult Reports()
        {
            try
            {
                var issueRepo  = new IssueRepo();
                var surveyRepo = new SurveyRepo();
                var issueList  = issueRepo.GetAll(x => x.SurveyId != null).ToList();

                var surveyList        = surveyRepo.GetAll().Where(x => x.IsDone).ToList();
                var totalSpeed        = 0.0;
                var totalTech         = 0.0;
                var totalPrice        = 0.0;
                var totalSatisfaction = 0.0;
                var totalSolving      = 0.0;
                var count             = issueList.Count;

                if (count == 0)
                {
                    TempData["Message2"] = "Rapor oluşturmak için yeterli kayıt bulunamadı.";
                    return(RedirectToAction("Index", "Home"));
                }

                foreach (var survey in surveyList)
                {
                    totalSpeed        += survey.Speed;
                    totalTech         += survey.TechPoint;
                    totalPrice        += survey.Pricing;
                    totalSatisfaction += survey.Satisfaction;
                    totalSolving      += survey.Solving;
                }

                var totalDays = 0;
                foreach (var issue in issueList)
                {
                    totalDays += issue.ClosedDate.Value.DayOfYear - issue.CreatedDate.DayOfYear;
                }

                ViewBag.AvgSpeed        = totalSpeed / count;
                ViewBag.AvgTech         = totalTech / count;
                ViewBag.AvgPrice        = totalPrice / count;
                ViewBag.AvgSatisfaction = totalSatisfaction / count;
                ViewBag.AvgSolving      = totalSolving / count;
                ViewBag.AvgTime         = totalDays / issueList.Count;

                return(View(surveyList));
            }
            catch (Exception ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Reports",
                    ControllerName = "Admin",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }
        public async Task <ActionResult> AssignTechAsync(IssueVM model)
        {
            try
            {
                var issue = new IssueRepo().GetById(model.IssueId);
                issue.TechnicianId = model.TechnicianId;
                issue.IssueState   = Models.Enums.IssueStates.Atandı;
                issue.OptReport    = model.OptReport;
                new IssueRepo().Update(issue);
                var technician = await NewUserStore().FindByIdAsync(issue.TechnicianId);

                TempData["Message"] =
                    $"{issue.Description} adlı arızaya {technician.Name}  {technician.Surname} teknisyeni atandı.";

                var customer     = NewUserManager().FindById(issue.CustomerId);
                var emailService = new EmailService();
                var body         = $"Merhaba <b>{GetNameSurname(issue.CustomerId)}</b><br>{issue.Description} adlı arızanız onaylanmıştır ve görevli teknisyen en kısa sürede yola çıkacaktır.";
                await emailService.SendAsync(new IdentityMessage()
                {
                    Body    = body,
                    Subject = $"{issue.Description} adlı arıza hk."
                }, customer.Email);

                var issueLog = new IssueLog()
                {
                    IssueId     = issue.Id,
                    Description = "Teknisyene atandı.",
                    FromWhom    = "Operatör"
                };
                new IssueLogRepo().Insert(issueLog);

                return(RedirectToAction("AllIssues", "Operator"));
            }
            catch (DbEntityValidationException ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu: {EntityHelpers.ValidationMessage(ex)}",
                    ActionName     = "AssignTechAsync",
                    ControllerName = "Operator",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
            catch (Exception ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "AssignTechAsync",
                    ControllerName = "Operator",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }
        public ActionResult ListAll()
        {
            var data = new IssueRepo().GetAll(x => x.ClosedDate != null);

            if (data == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View(data));
        }
        public ActionResult Details(string id)
        {
            var issue = new IssueRepo().GetById(id);

            if (issue == null)
            {
                TempData["Message2"] = "Arıza kaydı bulunamadi.";
                return(RedirectToAction("Index", "Issue"));
            }
            var data = Mapper.Map <Issue, IssueVM>(issue);

            data.PhotoPath = new PhotographRepo().GetAll(x => x.IssueId == id).Select(y => y.Path).ToList();
            return(View(data));
        }
        public ActionResult Details(string id)
        {
            ViewBag.TechnicianList = GetTechnicianList();

            var issue = new IssueRepo().GetById(id);

            if (issue == null)
            {
                TempData["Message2"] = "Arıza kaydı bulunamadi.";
                return(RedirectToAction("Index", "Operator"));
            }
            var userid = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();

            if (userid == null)
            {
                return(RedirectToAction("Index", "Issue"));
            }


            var data = Mapper.Map <Issue, IssueVM>(issue);

            if (issue.OperatorId == null)
            {
                issue.OperatorId = userid;
                if (new IssueRepo().Update(issue) > 0)
                {
                    issue.IssueState = Models.Enums.IssueStates.KabulEdildi;
                    data.IssueState  = issue.IssueState;
                    new IssueRepo().Update(issue);

                    var issueLog = new IssueLog()
                    {
                        IssueId     = issue.Id,
                        Description = "Operatör tarafından kabul edildi.",
                        FromWhom    = "Operatör"
                    };
                    new IssueLogRepo().Insert(issueLog);

                    return(View(data));
                }
            }

            return(View(data));
        }
Exemple #9
0
        public JsonResult GetTechReport()
        {
            try
            {
                var userManager = NewUserManager();
                var users       = userManager.Users.ToList();
                var data        = new List <TechReport>();
                foreach (var user in users)
                {
                    if (userManager.IsInRole(user.Id, IdentityRoles.Technician.ToString()))
                    {
                        var techIssues = new IssueRepo().GetAll(x => x.TechnicianId == user.Id);
                        foreach (var issue in techIssues)
                        {
                            if (issue.ClosedDate != null)
                            {
                                data.Add(new TechReport()
                                {
                                    nameSurname = GetNameSurname(user.Id),
                                    point       = double.Parse(GetTechPoint(user.Id))
                                });
                            }
                        }
                    }
                }

                return(Json(new ResponseData()
                {
                    success = true,
                    data = data
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    message = $"{ex.Message}",
                    success = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #10
0
        public ActionResult UpdateJob(IssueVM model)
        {
            try
            {
                var repo  = new IssueRepo();
                var issue = repo.GetById(model.IssueId);
                if (issue == null)
                {
                    TempData["Message2"] = "Arıza kaydı bulunamadi.";
                    return(RedirectToAction("Index", "Technician"));
                }

                issue.TechReport     = model.TechReport;
                issue.ServiceCharge += model.ServiceCharge;
                issue.UpdatedDate    = DateTime.Now;
                repo.Update(issue);

                var issueLog = new IssueLog()
                {
                    IssueId     = issue.Id,
                    Description = $"Güncelleme: {issue.TechReport}",
                    FromWhom    = "Teknisyen"
                };
                new IssueLogRepo().Insert(issueLog);

                return(RedirectToAction("Index", "Technician"));
            }
            catch (Exception ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu. {ex.Message}",
                    ActionName     = "UpdateJob",
                    ControllerName = "Technician",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }
Exemple #11
0
        public JsonResult GetJob(string id)
        {
            try
            {
                var issue = new IssueRepo().GetById(id);
                if (issue == null)
                {
                    return(Json(new ResponseData()
                    {
                        message = "Bulunamadi.",
                        success = false
                    }));
                }
                issue.IssueState = IssueStates.İşlemde;
                new IssueRepo().Update(issue);

                var issueLog = new IssueLog()
                {
                    IssueId     = issue.Id,
                    Description = "Teknisyen işi aldı.",
                    FromWhom    = "Teknisyen"
                };
                new IssueLogRepo().Insert(issueLog);

                return(Json(new ResponseData()
                {
                    message = "İş onayı başarılı",
                    success = true
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    message = $"Bir hata oluştu: {ex.Message}",
                    success = false
                }));
            }
        }
 public ActionResult AllIssues()
 {
     try
     {
         var data = new IssueRepo().GetAll().Select(x => Mapper.Map <IssueVM>(x)).ToList();
         if (data != null)
         {
             return(View(data));
         }
     }
     catch (Exception ex)
     {
         TempData["Message"] = new ErrorVM()
         {
             Text           = $"Bir hata oluştu {ex.Message}",
             ActionName     = "AllIssues",
             ControllerName = "Operator",
             ErrorCode      = 500
         };
         return(RedirectToAction("Error500", "Home"));
     }
     return(View());
 }
 public ActionResult Index()
 {
     try
     {
         var id   = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();
         var data = new IssueRepo().GetAll(x => x.CustomerId == id).Select(x => Mapper.Map <IssueVM>(x)).ToList();
         if (data != null)
         {
             return(View(data));
         }
     }
     catch (Exception ex)
     {
         TempData["Message"] = new ErrorVM()
         {
             Text           = $"Bir hata oluştu {ex.Message}",
             ActionName     = "Index",
             ControllerName = "Issue",
             ErrorCode      = 500
         };
         return(RedirectToAction("Error500", "Home"));
     }
     return(View());
 }
        protected List <SelectListItem> GetTechnicianList()
        {
            var data        = new List <SelectListItem>();
            var userManager = NewUserManager();
            var users       = userManager.Users.ToList();

            var techIds = new IssueRepo().GetAll(x => x.IssueState == IssueStates.İşlemde || x.IssueState == IssueStates.Atandı).Select(x => x.TechnicianId).ToList();

            foreach (var user in users)
            {
                if (userManager.IsInRole(user.Id, IdentityRoles.Technician.ToString()))
                {
                    if (!techIds.Contains(user.Id))
                    {
                        data.Add(new SelectListItem()
                        {
                            Text  = $"{user.Name} {user.Surname} ({GetTechPoint(user.Id)})",
                            Value = user.Id
                        });
                    }
                }
            }
            return(data);
        }
Exemple #15
0
 public AdminController()
 {
     issueRepo = new IssueRepo();
 }
        public async Task <ActionResult> Create(IssueVM model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Hata Oluştu.");
                return(RedirectToAction("Create", "Issue", model));
            }
            try
            {
                var id    = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();
                var user  = NewUserManager().FindById(id);
                var issue = new Issue()
                {
                    Description   = model.Description,
                    IssueState    = model.IssueState,
                    Location      = model.Location == Models.Enums.Locations.KonumYok ? user.Location : model.Location,
                    ProductType   = model.ProductType,
                    CustomerId    = model.CustomerId,
                    PurchasedDate = model.PurchasedDate,
                    PhotoPath     = model.PhotoPath,
                    ServiceCharge = model.ServiceCharge,
                    ClosedDate    = model.ClosedDate,
                    CreatedDate   = model.CreatedDate,
                    OperatorId    = model.OperatorId,
                    TechReport    = model.TechReport
                };
                switch (issue.ProductType)
                {
                case Models.Enums.ProductTypes.Buzdolabı:
                    if (issue.PurchasedDate.AddYears(1) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case Models.Enums.ProductTypes.BulaşıkMakinesi:
                    if (issue.PurchasedDate.AddYears(2) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case Models.Enums.ProductTypes.Fırın:
                    if (issue.PurchasedDate.AddYears(3) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case Models.Enums.ProductTypes.ÇamaşırMakinesi:
                    if (issue.PurchasedDate.AddYears(4) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case Models.Enums.ProductTypes.Mikrodalga:
                    if (issue.PurchasedDate.AddYears(5) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                default:
                    if (issue.PurchasedDate.AddYears(2) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;
                }
                if (issue.WarrantyState)
                {
                    issue.ServiceCharge = 0;
                }

                var repo = new IssueRepo();
                repo.Insert(issue);
                var fotorepo = new PhotographRepo();
                if (model.PostedPhoto.Count > 0)
                {
                    model.PostedPhoto.ForEach(file =>
                    {
                        if (file == null || file.ContentLength <= 0)
                        {
                            var filepath2 = Server.MapPath("~/assets/images/image-not-available.png");

                            var img2 = new WebImage(filepath2);
                            img2.Resize(250, 250, false);
                            img2.Save(filepath2);

                            fotorepo.Insert(new Photograph()
                            {
                                IssueId = issue.Id,
                                Path    = "/assets/images/image-not-available.png"
                            });

                            return;
                        }

                        var fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                        var extName       = Path.GetExtension(file.FileName);
                        fileName          = StringHelpers.UrlFormatConverter(fileName);
                        fileName         += StringHelpers.GetCode();
                        var directorypath = Server.MapPath("~/Upload/");
                        var filepath      = Server.MapPath("~/Upload/") + fileName + extName;

                        if (!Directory.Exists(directorypath))
                        {
                            Directory.CreateDirectory(directorypath);
                        }

                        file.SaveAs(filepath);

                        var img = new WebImage(filepath);
                        img.Resize(250, 250, false);
                        img.Save(filepath);

                        fotorepo.Insert(new Photograph()
                        {
                            IssueId = issue.Id,
                            Path    = "/Upload/" + fileName + extName
                        });
                    });
                }

                var fotograflar = fotorepo.GetAll(x => x.IssueId == issue.Id).ToList();
                var foto        = fotograflar.Select(x => x.Path).ToList();
                issue.PhotoPath = foto;
                repo.Update(issue);

                TempData["Message"] = "Arıza kaydınız başarı ile oluşturuldu.";

                var emailService = new EmailService();

                var body = $"Merhaba <b>{user.Name} {user.Surname}</b><br>Arıza kaydınız başarıyla oluşturuldu.Birimlerimiz sorunu çözmek için en kısa zamanda olay yerine intikal edecektir.<br><br> Ayrıntılı bilgi için telefon numaramız:<i>0212 684 75 33</i>";

                await emailService.SendAsync(new IdentityMessage()
                {
                    Body    = body,
                    Subject = "Arıza kaydı oluşturuldu."
                }, user.Email);

                var issueLog = new IssueLog()
                {
                    IssueId     = issue.Id,
                    Description = "Arıza Kaydı Oluşturuldu.",
                    FromWhom    = "Müşteri"
                };
                new IssueLogRepo().Insert(issueLog);

                return(RedirectToAction("Index", "Issue"));
            }
            catch (DbEntityValidationException ex)
            {
                TempData["Message3"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu: {EntityHelpers.ValidationMessage(ex)}",
                    ActionName     = "Create",
                    ControllerName = "Issue",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
            catch (Exception ex)
            {
                TempData["Message2"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Create",
                    ControllerName = "Issue",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }