public ActionResult FailureList() { var techId = System.Web.HttpContext.Current.User.Identity.GetUserId(); try { var data = new FailureRepo() .GetAll() .Select(x => Mapper.Map <FailureViewModel>(x)) .Where(x => x.TechnicianId == techId) .OrderBy(x => x.OperationTime) .ToList(); return(View(data)); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Index", ControllerName = "Home", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
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 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")); } }
// GET: Operator public ActionResult Index() { var data = new FailureRepo() .GetAll() .Select(x => Mapper.Map <FailureViewModel>(x)) .ToList(); return(View(data)); }
public ActionResult GetAllFailures() { var data = new FailureRepo().GetAll(x => x.FinishingTime != null); if (data == null) { return(RedirectToAction("Index", "Home")); } return(View(data)); }
public async Task <ActionResult> Decline(FailureViewModel model) { try { var failure = new FailureRepo().GetById(model.FailureId); if (failure.OperationStatus == OperationStatuses.Declined) { TempData["Message"] = $"{failure.Id} nolu arıza zaten reddedilmiştir."; return(RedirectToAction("Detail", "Operator", new { id = model.FailureId })); } failure.OperationStatus = OperationStatuses.Declined; failure.OperationTime = DateTime.Now; failure.OperatorId = System.Web.HttpContext.Current.User.Identity.GetUserId(); failure.Report = model.Report; new FailureRepo().Update(failure); new OperationRepo().Insert(new Operation() { FailureId = failure.Id, Message = $"Arızanız şu nedenden dolayı reddedilmiştir: {failure.Report}", FromWhom = IdentityRoles.Operator }); TempData["Message"] = $"{failure.Id} nolu arıza reddedilmiştir."; var emailService = new EmailService(); var body = $"Merhaba <b>{failure.Client.Name} {failure.Client.Surname}</b><br>{failure.FailureName} adlı arızanız şu nedenden dolayı reddedilmiştir:<br><br>{failure.Report}<br><br>İyi günler dileriz."; await emailService.SendAsync(new IdentityMessage() { Body = body, Subject = $"{failure.FailureName} adlı arızanız reddedilmiştir. | Teknik Servisçi" }, failure.Client.Email); return(RedirectToAction("Detail", "Operator", new { id = model.FailureId })); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Decline", ControllerName = "Operator", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
public async Task <ActionResult> TechnicianAdd(FailureViewModel model) { try { var failure = new FailureRepo().GetById(model.FailureId); failure.TechnicianId = model.TechnicianId; failure.OperationTime = DateTime.Now; failure.OperatorId = System.Web.HttpContext.Current.User.Identity.GetUserId(); failure.OperationStatus = OperationStatuses.Accepted; new FailureRepo().Update(failure); var technician = await NewUserStore().FindByIdAsync(failure.TechnicianId); TempData["Message"] = $"{failure.Id} nolu arızaya {technician.Name} {technician.Surname} atanmıştır.İyi çalışmalar."; new OperationRepo().Insert(new Operation() { FailureId = model.FailureId, Message = $"Arızaya yeni teknisyen atanmıştır: {technician.Name} {technician.Surname}", FromWhom = IdentityRoles.Operator }); var emailService = new EmailService(); var body = $"Merhaba <b>{failure.Client.Name} {failure.Client.Surname}</b><br>{failure.FailureName} adlı arızanız onaylanmış ve alanında uzman teknisyenlerimizden birine atanmıştır. Sizinle yeniden iletişime geçilecektir.<br><br>İyi günler dileriz."; await emailService.SendAsync(new IdentityMessage() { Body = body, Subject = $"{failure.FailureName} adlı arızanız onaylanmıştır. | Teknik Servisçi" }, failure.Client.Email); return(RedirectToAction("Detail", "Operator", new { id = model.FailureId })); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "TechnicianAdd", ControllerName = "Operator", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
public ActionResult TechnicianReport(int id) { try { var failure = new FailureRepo().GetById(id); var data = Mapper.Map <FailureViewModel>(failure); return(View(data)); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "TechnicianReport", ControllerName = "Technician", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
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 techFailures = new FailureRepo().GetAll(x => x.TechnicianId == user.Id); foreach (var failure in techFailures) { if (failure.FinishingTime != 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}", success = false }, JsonRequestBehavior.AllowGet)); } }
public ActionResult FailureList() { try { var data = new FailureRepo() .GetAll() .Select(x => Mapper.Map <FailureViewModel>(x)) .OrderBy(x => x.OperationTime) .ToList(); return(View(data)); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Index", ControllerName = "Admin", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
protected List <SelectListItem> GetTechnicianList() { var data = new List <SelectListItem>(); var userManager = NewUserManager(); var users = userManager.Users.ToList(); var techIds = new FailureRepo().GetAll(x => x.Technician.TechnicianStatus == TechnicianStatuses.OnWay || x.Technician.TechnicianStatus == TechnicianStatuses.OnWork).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); }
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 AdminController() { failureRepo = new FailureRepo(); }
public ActionResult Add(FailureViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { model.ClientId = System.Web.HttpContext.Current.User.Identity.GetUserId(); var data = Mapper.Map <FailureViewModel, Failure>(model); var failureRepo = new FailureRepo(); failureRepo.Insert(data); var photoRepo = new PhotoRepo(); if (model.PostedPhoto.Count > 0) { model.PostedPhoto.ForEach(file => { if (file == null || file.ContentLength <= 0) { return; } string fileName = "failure-"; fileName += Path.GetFileNameWithoutExtension(file.FileName); string extName = Path.GetExtension(file.FileName); fileName = StringHelpers.UrlFormatConverter(fileName); fileName += StringHelpers.GetCode(); var klasoryolu = Server.MapPath("~/Upload/Failure/"); var dosyayolu = Server.MapPath("~/Upload/Failure/") + fileName + extName; if (!Directory.Exists(klasoryolu)) { Directory.CreateDirectory(klasoryolu); } file.SaveAs(dosyayolu); WebImage img = new WebImage(dosyayolu); img.Resize(800, 600, false); img.AddTextWatermark("Teknik Servisçi"); img.Save(dosyayolu); photoRepo.Insert(new Photo() { FailureId = data.Id, Path = "/Upload/Failure/" + fileName + extName }); }); } var photos = photoRepo.GetAll(x => x.FailureId == data.Id).ToList(); var photo = photos.Select(x => x.Path).ToList(); data.PhotoPath = photo; failureRepo.Update(data); new OperationRepo().Insert(new Operation() { FailureId = data.Id, Message = $"#{data.Id} - {data.FailureName} adlı arıza kaydı oluşturuldu.", FromWhom = IdentityRoles.User }); TempData["Message"] = $"{model.FailureName} adlı arızanız operatörlerimizce incelenecektir ve size 24 saat içinde dönüş yapılacaktır."; return(RedirectToAction("Add")); } catch (DbEntityValidationException ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu: {EntityHelpers.ValidationMessage(ex)}", ActionName = "Add", ControllerName = "Failure", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu: {ex.Message}", ActionName = "Add", ControllerName = "Failure", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }