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