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 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")); } }