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"); }
public ActionResult Survey(string code) { try { var surveyRepo = new SurveyRepo(); var survey = surveyRepo.GetById(code); if (survey.IsDone == true) { TempData["Message2"] = "Bu anket zaten tamamlanmış."; return(RedirectToAction("Index", "Home")); } if (survey == null) { return(RedirectToAction("Index", "Home")); } var data = Mapper.Map <Survey, SurveyVM>(survey); return(View(data)); } catch (Exception ex) { TempData["Message2"] = new ErrorVM() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Survey", ControllerName = "Issue", ErrorCode = 500 }; return(RedirectToAction("Error500", "Home")); } }
public bool ProcessSurveyResponses(int clientid, int surveyid, string responses) { bool didProcess = true; string path = Server.MapPath("~/logs/log.txt"); string reqPath = Server.MapPath("~/logs/request.txt"); SurveyRepo repo = new SurveyRepo(); SurveyResponseVM vm = new SurveyResponseVM { ClientID = clientid, SurveyID = surveyid, ResponseString = responses }; try { repo.SubmitResponses(vm); } catch (Exception ex) { using (StreamWriter writer = new StreamWriter(path, true)) { writer.WriteLine(string.Concat(DateTime.Now.ToLongDateString(), " :", ex.Message)); didProcess = false; } } return(didProcess); }
public ActionResult Reports() { try { var failureRepo = new FailureRepo(); var surveyRepo = new SurveyRepo(); var failureList = failureRepo.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 = failureList.Count; if (count == 0) { TempData["Message"] = "Herhangi bir 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 failure in failureList) { if (failure.FinishingTime.HasValue) { totalDays += failure.FinishingTime.Value.DayOfYear - failure.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 / failureList.Count; return(View(surveyList)); } catch (Exception ex) { TempData["Message"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Reports", ControllerName = "Admin", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
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")); } }
public ActionResult GetClientList() { SurveyRepo repo = new SurveyRepo(); ClientSurveysVM clientSurveys = new ClientSurveysVM(); clientSurveys.ClientSurveyList = repo.GetClientSurveys(); return(PartialView(clientSurveys)); }
public ActionResult Get(int cid, int sid) { SurveyRepo repo = new SurveyRepo(); SurveyVM surveyvm = repo.GetSurvey(sid); surveyvm.ClientID = cid; return(View(surveyvm)); }
public ActionResult CreateInvoice(FailureViewModel model) { try { var failure = new FailureRepo().GetById(model.FailureId); if (model.HasWarranty) { failure.Price = 0m; } else { failure.Price = model.Price; } failure.HasWarranty = model.HasWarranty; failure.Report = model.Report; failure.RepairProcess = model.RepairProcess; new FailureRepo().Update(failure); TempData["Message"] = $"{model.FailureId} no lu arıza için tutar girilmiştir."; //var survey = new SurveyRepo().GetById(model.FailureId); var survey = new Survey(); var surveyRepo = new SurveyRepo(); surveyRepo.Insert(survey); failure.SurveyId = survey.Id; surveyRepo.Update(survey); var user = NewUserManager().FindById(failure.ClientId); var clientNameSurname = GetNameSurname(failure.ClientId); 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>{clientNameSurname}</b><br>{failure.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}/failure/survey?code={failure.SurveyId}' >Anket Linki </a> "; emailService.Send(new IdentityMessage() { Body = body, Subject = "Değerlendirme Anketi" }, user.Email); return(RedirectToAction("Detail", "Technician", new { id = model.FailureId })); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Detail", ControllerName = "Operator", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
public ActionResult GetSurveyResponse(int surveyResponseID) { SurveyRepo repo = new SurveyRepo(); ClientSurveyVM vm = repo.GetSurveyResponse(surveyResponseID); vm.Questions = vm.QuestionString.Split('?').Where(s => !string.IsNullOrEmpty(s)).ToList(); vm.Responses = vm.ResponseString.Split('~').ToList(); return(PartialView(vm)); }
public JsonResult GetSurveyReport() { try { var surveys = new SurveyRepo(); var count = surveys.GetAll().Count; var quest1 = surveys.GetAll().Select(x => x.Satisfaction).Sum() / count; var quest2 = surveys.GetAll().Select(x => x.TechPoint).Sum() / count; var quest3 = surveys.GetAll().Select(x => x.Speed).Sum() / count; var quest4 = surveys.GetAll().Select(x => x.Pricing).Sum() / count; var quest5 = surveys.GetAll().Select(x => x.Solving).Sum() / count; var data = new List <SurveyReport>(); data.Add(new SurveyReport() { question = "Genel Memnuniyet", point = quest1 }); data.Add(new SurveyReport() { question = "Teknisyen", point = quest2 }); data.Add(new SurveyReport() { question = "Hız", point = quest3 }); data.Add(new SurveyReport() { question = "Fiyat", point = quest4 }); data.Add(new SurveyReport() { question = "Çözüm Odaklılık", point = quest5 }); return(Json(new ResponseData() { message = $"{data.Count} adet kayıt bulundu", success = true, data = data }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new ResponseData() { message = "Kayıt bulunamadı" + ex.Message, success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Survey(SurveyVM model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Hata Oluştu."); return(RedirectToAction("Survey", "Issue", model)); } try { var surveyRepo = new SurveyRepo(); var survey = surveyRepo.GetById(model.SurveyId); if (survey == null) { return(RedirectToAction("Index", "Home")); } survey.Pricing = model.Pricing; survey.Satisfaction = model.Satisfaction; survey.Solving = model.Solving; survey.Speed = model.Speed; survey.TechPoint = model.TechPoint; survey.Suggestions = model.Suggestions; survey.IsDone = true; surveyRepo.Update(survey); TempData["Message"] = "Anket tamamlandı."; return(RedirectToAction("UserProfile", "Account")); } catch (Exception ex) { TempData["Message2"] = new ErrorVM() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Survey", ControllerName = "Issue", ErrorCode = 500 }; return(RedirectToAction("Error500", "Home")); } }
public static string GetTechPoint(string techId) { var tech = NewUserManager().FindById(techId); if (tech == null) { return("0"); } var failures = new FailureRepo().GetAll(x => x.TechnicianId == techId /*&& x.Survey.IsDone == true*/); if (failures == null) { return("0"); } var isDoneFailures = new List <Failure>(); foreach (var failure in failures) { var survey = new SurveyRepo().GetById(failure.SurveyId); if (survey.IsDone) { isDoneFailures.Add(failure); } } var count = 0.0; foreach (var item in isDoneFailures) { var survey = new SurveyRepo().GetById(item.SurveyId); count += survey.TechPoint; } //return $"{count / failures.Count}"; return(isDoneFailures.Count != 0 ? $"{count / isDoneFailures.Count}" : "0"); }
public void PostItemResource(ItemResource Item) { SurveyRepo sr = new SurveyRepo(); sr.PostItemResource(Item); }
public SurveyController(SurveyRepo surveyRepo, WasteAppDbContext db) { _surveyRepo = surveyRepo; _db = db; }
public SurveyController() { SurveyRepo repository = new SurveyRepo(); _service = new SurveyService(repository); }