public ActionResult CreateInvoice(FailureViewModel model) { try { var failure = _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; _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(); _surveyRepo.Insert(survey); failure.SurveyId = survey.Id; _surveyRepo.Update(survey); var user = _membershipTools.UserManager.FindByIdAsync(failure.ClientId).Result; var clientNameSurname = _membershipTools.GetNameSurname(failure.ClientId); var uri = new UriBuilder() { Scheme = Uri.UriSchemeHttps }; var hostComponents = Request.Host.ToUriComponent(); string siteUrl = uri.Scheme + System.Uri.SchemeDelimiter + hostComponents; EmailService emailService = new EmailService(); var body = $"Merhaba <b>{clientNameSurname.Result}</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 EmailModel() { Body = body, Subject = "Değerlendirme Anketi" }, user.Email); return(RedirectToAction("Detail", "Technician", new { id = model.FailureId })); } catch (Exception ex) { var mdl = new ErrorViewModel() { Text = $"Bir hata oluştu: {ex.Message}", ActionName = "CreateInvoice", ControllerName = "Technician", ErrorCode = "500" }; TempData["ErrorMessage"] = JsonConvert.SerializeObject(mdl); return(RedirectToAction("Error", "Home")); } }
public async Task <JsonResult> GetTechReport() { try { var userManager = _membershipTools.UserManager; var users = userManager.Users.ToList(); var data = new List <TechReport>(); foreach (var user in users) { if (await userManager.IsInRoleAsync(user, IdentityRoles.Technician.ToString())) { var techIssues = _issueRepo.GetAll(x => x.TechnicianId == user.Id); foreach (var issue in techIssues) { if (issue.ClosedDate != null) { data.Add(new TechReport() { nameSurname = await _membershipTools.GetNameSurname(user.Id), point = double.Parse(await _membershipTools.GetTechPoint(user.Id)) }); } } } } return(Json(new ResponseData() { success = true, data = data })); } catch (Exception ex) { return(Json(new ResponseData() { message = $"{ex.Message}", success = false })); } }
public async Task <ActionResult> AssignTech(IssueVM model) { try { var issue = _issueRepo.GetById(model.IssueId); issue.TechnicianId = model.TechnicianId; issue.IssueState = IssueStates.Atandı; issue.OptReport = model.OptReport; _issueRepo.Update(issue); var technician = await _membershipTools.NewUserStore().FindByIdAsync(issue.TechnicianId); TempData["Message"] = $"{issue.Description} adlı arızaya {technician.Name} {technician.Surname} teknisyeni atandı."; var customer = await _membershipTools.UserManager.FindByIdAsync(issue.CustomerId); var emailService = new EmailService(); var body = $"Merhaba <b>{await _membershipTools.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 EmailModel() { Body = body, Subject = $"{issue.Description} adlı arıza hk." }, customer.Email); var issueLog = new IssueLog() { IssueId = issue.Id, Description = "Teknisyene atandı.", FromWhom = "Operatör" }; _issueLogRepo.Insert(issueLog); return(RedirectToAction("AllIssues", "Operator")); } catch (Exception ex) { var errorVM = new ErrorVM() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "AssignTechAsync", ControllerName = "Operator", ErrorCode = "500" }; TempData["ErrorMessage"] = JsonConvert.SerializeObject(errorVM); return(RedirectToAction("Error500", "Home")); } }
public async Task <ActionResult> TechnicianAdd(FailureViewModel model) { try { var failure = _failureRepo.GetById(model.FailureId); failure.TechnicianId = model.TechnicianId; failure.OperationTime = DateTime.Now; failure.OperatorId = _membershipTools.UserManager.GetUserAsync(HttpContext.User).Result.Id; failure.OperationStatus = OperationStatuses.Accepted; _failureRepo.Update(failure); var technician = _membershipTools.UserManager.FindByIdAsync(failure.TechnicianId).Result; TempData["Message"] = $"{failure.Id} nolu arızaya {technician.Name} {technician.Surname} atanmıştır.İyi çalışmalar."; _failureLogRepo.Insert(new FailureLog() { 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>{_membershipTools.GetNameSurname(failure.ClientId).Result}</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 EmailModel() { 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) { var mdl = new ErrorViewModel() { Text = $"Bir hata oluştu: {ex.Message}", ActionName = "TechnicianAdd", ControllerName = "Operator", ErrorCode = "500" }; TempData["ErrorMessage"] = JsonConvert.SerializeObject(mdl); return(RedirectToAction("Error", "Home")); } }
public async Task <ActionResult> FinishJob(IssueVM model) { try { var issueRepo = _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 = _surveyRepo; surveyRepo.Insert(survey); issue.SurveyId = survey.Id; issueRepo.Update(issue); var user = await _membershipTools.NewUserStore().FindByIdAsync(issue.CustomerId); var usernamesurname = await _membershipTools.GetNameSurname(issue.CustomerId); var uri = new UriBuilder() { Scheme = Uri.UriSchemeHttps }; var hostComponents = Request.Host.ToUriComponent(); string SiteUrl = uri.Scheme + System.Uri.SchemeDelimiter + hostComponents; 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 EmailModel() { Body = body, Subject = "Değerlendirme Anketi" }, user.Email); var issueLog = new IssueLog() { IssueId = issue.Id, Description = "İş tamamlandı.", FromWhom = "Teknisyen" }; _issueLogRepo.Insert(issueLog); return(RedirectToAction("Index", "Technician")); } catch (Exception ex) { var errorVM = new ErrorVM() { Text = $"Bir hata oluştu. {ex.Message}", ActionName = "FinishJob", ControllerName = "Technician", ErrorCode = "500" }; TempData["ErrorMessage"] = JsonConvert.SerializeObject(errorVM); return(RedirectToAction("Error500", "Home")); } }