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 UpdateJob(IssueVM model) { try { var repo = new IssueRepo(); var issue = repo.GetById(model.IssueId); if (issue == null) { TempData["Message2"] = "Arıza kaydı bulunamadi."; return(RedirectToAction("Index", "Technician")); } issue.TechReport = model.TechReport; issue.ServiceCharge += model.ServiceCharge; issue.UpdatedDate = DateTime.Now; repo.Update(issue); var issueLog = new IssueLog() { IssueId = issue.Id, Description = $"Güncelleme: {issue.TechReport}", 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 = "UpdateJob", ControllerName = "Technician", ErrorCode = 500 }; return(RedirectToAction("Error500", "Home")); } }
public async Task <ActionResult> Create(IssueVM model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Hata Oluştu."); return(RedirectToAction("Create", "Issue", model)); } try { var id = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId(); var user = NewUserManager().FindById(id); var issue = new Issue() { Description = model.Description, IssueState = model.IssueState, Location = model.Location == Models.Enums.Locations.KonumYok ? user.Location : model.Location, ProductType = model.ProductType, CustomerId = model.CustomerId, PurchasedDate = model.PurchasedDate, PhotoPath = model.PhotoPath, ServiceCharge = model.ServiceCharge, ClosedDate = model.ClosedDate, CreatedDate = model.CreatedDate, OperatorId = model.OperatorId, TechReport = model.TechReport }; switch (issue.ProductType) { case Models.Enums.ProductTypes.Buzdolabı: if (issue.PurchasedDate.AddYears(1) > DateTime.Now) { issue.WarrantyState = true; } break; case Models.Enums.ProductTypes.BulaşıkMakinesi: if (issue.PurchasedDate.AddYears(2) > DateTime.Now) { issue.WarrantyState = true; } break; case Models.Enums.ProductTypes.Fırın: if (issue.PurchasedDate.AddYears(3) > DateTime.Now) { issue.WarrantyState = true; } break; case Models.Enums.ProductTypes.ÇamaşırMakinesi: if (issue.PurchasedDate.AddYears(4) > DateTime.Now) { issue.WarrantyState = true; } break; case Models.Enums.ProductTypes.Mikrodalga: if (issue.PurchasedDate.AddYears(5) > DateTime.Now) { issue.WarrantyState = true; } break; default: if (issue.PurchasedDate.AddYears(2) > DateTime.Now) { issue.WarrantyState = true; } break; } if (issue.WarrantyState) { issue.ServiceCharge = 0; } var repo = new IssueRepo(); repo.Insert(issue); var fotorepo = new PhotographRepo(); if (model.PostedPhoto.Count > 0) { model.PostedPhoto.ForEach(file => { if (file == null || file.ContentLength <= 0) { var filepath2 = Server.MapPath("~/assets/images/image-not-available.png"); var img2 = new WebImage(filepath2); img2.Resize(250, 250, false); img2.Save(filepath2); fotorepo.Insert(new Photograph() { IssueId = issue.Id, Path = "/assets/images/image-not-available.png" }); return; } var fileName = Path.GetFileNameWithoutExtension(file.FileName); var extName = Path.GetExtension(file.FileName); fileName = StringHelpers.UrlFormatConverter(fileName); fileName += StringHelpers.GetCode(); var directorypath = Server.MapPath("~/Upload/"); var filepath = Server.MapPath("~/Upload/") + fileName + extName; if (!Directory.Exists(directorypath)) { Directory.CreateDirectory(directorypath); } file.SaveAs(filepath); var img = new WebImage(filepath); img.Resize(250, 250, false); img.Save(filepath); fotorepo.Insert(new Photograph() { IssueId = issue.Id, Path = "/Upload/" + fileName + extName }); }); } var fotograflar = fotorepo.GetAll(x => x.IssueId == issue.Id).ToList(); var foto = fotograflar.Select(x => x.Path).ToList(); issue.PhotoPath = foto; repo.Update(issue); TempData["Message"] = "Arıza kaydınız başarı ile oluşturuldu."; var emailService = new EmailService(); var body = $"Merhaba <b>{user.Name} {user.Surname}</b><br>Arıza kaydınız başarıyla oluşturuldu.Birimlerimiz sorunu çözmek için en kısa zamanda olay yerine intikal edecektir.<br><br> Ayrıntılı bilgi için telefon numaramız:<i>0212 684 75 33</i>"; await emailService.SendAsync(new IdentityMessage() { Body = body, Subject = "Arıza kaydı oluşturuldu." }, user.Email); var issueLog = new IssueLog() { IssueId = issue.Id, Description = "Arıza Kaydı Oluşturuldu.", FromWhom = "Müşteri" }; new IssueLogRepo().Insert(issueLog); return(RedirectToAction("Index", "Issue")); } catch (DbEntityValidationException ex) { TempData["Message3"] = new ErrorVM() { Text = $"Bir hata oluştu: {EntityHelpers.ValidationMessage(ex)}", ActionName = "Create", ControllerName = "Issue", ErrorCode = 500 }; return(RedirectToAction("Error500", "Home")); } catch (Exception ex) { TempData["Message2"] = new ErrorVM() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "Create", ControllerName = "Issue", ErrorCode = 500 }; return(RedirectToAction("Error500", "Home")); } }