Example #1
0
        private IssueLogListingModel BuildIssueLogForEdit(IssueLog issueLog)
        {
            var model = new IssueLogListingModel
            {
                Id                           = issueLog.Id,
                CompanyId                    = issueLog.Project.Company.Id,
                CompanyName                  = issueLog.Project.Company.Name,
                ProjectId                    = issueLog.Project.Id,
                ProjectName                  = issueLog.Project.Name,
                IssueDate                    = issueLog.IssueDate,
                Header                       = issueLog.Header,
                Body                         = issueLog.Body,
                Note                         = issueLog.Note,
                EntryBy                      = issueLog.EntryBy,
                AssignBy                     = issueLog.AssignBy,
                AssignDate                   = issueLog.AssignDate,
                AssignRemarks                = issueLog.AssignRemarks,
                IssueLogInvolvedPersons      = BuildIssueLogInvolvedPerson(issueLog.IssueLogInvolvedPersons),
                Priority                     = issueLog.Priority,
                TaskHour                     = issueLog.TaskHour,
                IssueType                    = issueLog.IssueType,
                ApplicationUserListingModels = BuildApplicationUserList(),
                IsAllCompletedExceptOwn      = issueLog.IssueLogInvolvedPersons.Where(y => y.InvolvedPerson.Id != _userManager.GetUserId(User) && y.IsComplete).ToList().Count == (issueLog.IssueLogInvolvedPersons.Count() - 1)
            };

            return(model);
        }
Example #2
0
        public void Edit(IssueLog issueLog)
        {
            var issueLogSaved = GetById(issueLog.Id);

            var issueLogInvolvedPersons = issueLogSaved.IssueLogInvolvedPersons;

            if (issueLogInvolvedPersons.Any())
            {
                foreach (var issueLogInvolvedPerson in issueLogInvolvedPersons)
                {
                    _context.Entry(issueLogInvolvedPerson).State = EntityState.Deleted;
                }
            }
            //_context.IssueLogInvolvedPerson.RemoveRange(issueLogSaved.IssueLogInvolvedPersons);
            issueLogSaved.Id                      = issueLogSaved.Id;
            issueLogSaved.Project                 = issueLog.Project;
            issueLogSaved.IssueDate               = issueLog.IssueDate;
            issueLogSaved.Header                  = issueLog.Header;
            issueLogSaved.Body                    = issueLog.Body;
            issueLogSaved.Note                    = issueLog.Note;
            issueLogSaved.EntryBy                 = issueLog.EntryBy;
            issueLogSaved.AssignBy                = issueLog.AssignBy;
            issueLogSaved.AssignDate              = issueLog.AssignDate;
            issueLogSaved.AssignRemarks           = issueLog.AssignRemarks;
            issueLogSaved.IssueLogInvolvedPersons = issueLog.IssueLogInvolvedPersons;
            issueLogSaved.Priority                = issueLog.Priority;
            issueLogSaved.TaskHour                = issueLog.TaskHour;
            issueLogSaved.IssueType               = issueLog.IssueType;
            issueLogSaved.IsComplete              = issueLog.IsComplete;

            //_context.IssueLog.Update(issueLogSaved);

            _context.SaveChanges();
        }
Example #3
0
        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 async Task <ActionResult> AssignTechAsync(IssueVM model)
        {
            try
            {
                var issue = new IssueRepo().GetById(model.IssueId);
                issue.TechnicianId = model.TechnicianId;
                issue.IssueState   = Models.Enums.IssueStates.Atandı;
                issue.OptReport    = model.OptReport;
                new IssueRepo().Update(issue);
                var technician = await NewUserStore().FindByIdAsync(issue.TechnicianId);

                TempData["Message"] =
                    $"{issue.Description} adlı arızaya {technician.Name}  {technician.Surname} teknisyeni atandı.";

                var customer     = NewUserManager().FindById(issue.CustomerId);
                var emailService = new EmailService();
                var body         = $"Merhaba <b>{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 IdentityMessage()
                {
                    Body    = body,
                    Subject = $"{issue.Description} adlı arıza hk."
                }, customer.Email);

                var issueLog = new IssueLog()
                {
                    IssueId     = issue.Id,
                    Description = "Teknisyene atandı.",
                    FromWhom    = "Operatör"
                };
                new IssueLogRepo().Insert(issueLog);

                return(RedirectToAction("AllIssues", "Operator"));
            }
            catch (DbEntityValidationException ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu: {EntityHelpers.ValidationMessage(ex)}",
                    ActionName     = "AssignTechAsync",
                    ControllerName = "Operator",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
            catch (Exception ex)
            {
                TempData["Message"] = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "AssignTechAsync",
                    ControllerName = "Operator",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error500", "Home"));
            }
        }
Example #5
0
        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"));
            }
        }
Example #6
0
        // Log dialogues

        private void LblIssues_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (IssueLogForm == null)
                {
                    IssueLogForm = new IssueLog(this);
                }

                IssueLogForm.ShowDialog();
            }
            catch
            {
                IssueLogForm = new IssueLog(this);
                IssueLogForm.ShowDialog();
            }
        }
        public ActionResult Details(string id)
        {
            ViewBag.TechnicianList = GetTechnicianList();

            var issue = new IssueRepo().GetById(id);

            if (issue == null)
            {
                TempData["Message2"] = "Arıza kaydı bulunamadi.";
                return(RedirectToAction("Index", "Operator"));
            }
            var userid = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId();

            if (userid == null)
            {
                return(RedirectToAction("Index", "Issue"));
            }


            var data = Mapper.Map <Issue, IssueVM>(issue);

            if (issue.OperatorId == null)
            {
                issue.OperatorId = userid;
                if (new IssueRepo().Update(issue) > 0)
                {
                    issue.IssueState = Models.Enums.IssueStates.KabulEdildi;
                    data.IssueState  = issue.IssueState;
                    new IssueRepo().Update(issue);

                    var issueLog = new IssueLog()
                    {
                        IssueId     = issue.Id,
                        Description = "Operatör tarafından kabul edildi.",
                        FromWhom    = "Operatör"
                    };
                    new IssueLogRepo().Insert(issueLog);

                    return(View(data));
                }
            }

            return(View(data));
        }
Example #8
0
        public RunLog AnalyzeFile(string fileName)
        {
            string path   = Path.GetTempFileName();
            RunLog runLog = null;

            try
            {
                var options = new AnalyzeOptions()
                {
                    BinaryFileSpecifiers = new string[] { fileName },
                    Verbose            = true,
                    Statistics         = true,
                    ComputeTargetsHash = true,
                    PolicyFilePath     = "default",
                    Recurse            = true,
                    OutputFilePath     = path,
                    SymbolsPath        = "SRV*http://symweb"
                };

                var command = new AnalyzeCommand();
                int result  = command.Run(options);
                Assert.Equal(AnalyzeCommand.SUCCESS, result);

                JsonSerializerSettings settings = new JsonSerializerSettings()
                {
                    ContractResolver = SarifContractResolver.Instance
                };

                IssueLog log = JsonConvert.DeserializeObject <IssueLog>(File.ReadAllText(path), settings);
                Assert.NotNull(log);
                Assert.Equal <int>(1, log.RunLogs.Count);

                runLog = log.RunLogs[0];
            }
            finally
            {
                File.Delete(path);
            }

            return(runLog);
        }
        // Log dialogues

        private void LblIssues_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (IssueLogForm == null)
                {
                    IssueLogForm = new IssueLog(this);
                }

                var result = IssueLogForm.ShowDialog();
                if (result == DialogResult.Yes)
                {
                    Restart();
                }
            }
            catch
            {
                IssueLogForm = new IssueLog(this);
                IssueLogForm.ShowDialog();
            }
        }
Example #10
0
        public ActionResult UpdateJob(IssueVM model)
        {
            try
            {
                var repo  = _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"
                };
                _issueLogRepo.Insert(issueLog);

                return(RedirectToAction("Index", "Technician"));
            }
            catch (Exception ex)
            {
                var errorVM = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu. {ex.Message}",
                    ActionName     = "UpdateJob",
                    ControllerName = "Technician",
                    ErrorCode      = "500"
                };
                TempData["ErrorMessage"] = JsonConvert.SerializeObject(errorVM);
                return(RedirectToAction("Error500", "Home"));
            }
        }
Example #11
0
        private IssueLog BuildIssueLogForCreate(IssueLogListingModelForAjax model, ApplicationUser applicationUser, IEnumerable <ApplicationUser> involvedPersons)
        {
            bool isAllComplted = false;

            bool.TryParse(model.IsAllCompletedExceptOwn, out isAllComplted);
            var issueLog = new IssueLog
            {
                Project    = BuildProject(int.Parse(model.ProjectId)),
                IssueDate  = DateTime.Parse(model.IssueDate),
                Header     = model.Header,
                Body       = model.Body,
                Note       = model.Note,
                EntryBy    = applicationUser,
                AssignDate = DateTime.Now,
                IssueLogInvolvedPersons = BuildIssueLogInvolvedPerson(involvedPersons, isAllComplted),
                Priority  = (EnumIssuePriority)int.Parse(model.Priority),
                TaskHour  = double.Parse(model.TaskHour),
                IssueType = (EnumIssueType)int.Parse(model.IssueType)
            };

            return(issueLog);
        }
Example #12
0
        public JsonResult GetJob(string id)
        {
            try
            {
                var issue = _issueRepo.GetById(id);
                if (issue == null)
                {
                    return(Json(new ResponseData()
                    {
                        message = "Bulunamadi.",
                        success = false
                    }));
                }
                issue.IssueState = IssueStates.İşlemde;
                _issueRepo.Update(issue);

                var issueLog = new IssueLog()
                {
                    IssueId     = issue.Id,
                    Description = "Teknisyen işi aldı.",
                    FromWhom    = "Teknisyen"
                };
                _issueLogRepo.Insert(issueLog);

                return(Json(new ResponseData()
                {
                    message = "İş onayı başarılı",
                    success = true
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ResponseData()
                {
                    message = $"Bir hata oluştu: {ex.Message}",
                    success = false
                }));
            }
        }
Example #13
0
        public async Task <ActionResult> Create(IssueVM model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Hata Oluştu.");
                return(RedirectToAction("Create", "Issue", model));
            }
            try
            {
                var user = await _membershipTools.UserManager.GetUserAsync(HttpContext.User);

                var issue = new Issue()
                {
                    Description   = model.Description,
                    IssueState    = model.IssueState,
                    Latitude      = model.Latitude,
                    Longitude     = model.Longitude,
                    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 ProductTypes.Buzdolabı:
                    if (issue.PurchasedDate.AddYears(1) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case ProductTypes.BulaşıkMakinesi:
                    if (issue.PurchasedDate.AddYears(2) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case ProductTypes.Fırın:
                    if (issue.PurchasedDate.AddYears(3) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case ProductTypes.ÇamaşırMakinesi:
                    if (issue.PurchasedDate.AddYears(4) > DateTime.Now)
                    {
                        issue.WarrantyState = true;
                    }
                    break;

                case 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 = _issueRepo;
                repo.Insert(issue);
                var fotorepo = _photographRepo;
                if (model.PostedPhoto.Count > 0)
                {
                    model.PostedPhoto.ForEach(async file =>
                    {
                        if (file == null || file.Length <= 0)
                        {
                            var filepath2 = Path.Combine("/assets/images/image-not-available.png");

                            using (var fileStream = new FileStream(filepath2, FileMode.Create))
                            {
                                await file.CopyToAsync(fileStream);
                            }
                            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 webpath       = _hostingEnvironment.WebRootPath;
                        var directorypath = Path.Combine(webpath, "Uploads");
                        var filePath      = Path.Combine(directorypath, fileName + extName);

                        if (!Directory.Exists(directorypath))
                        {
                            Directory.CreateDirectory(directorypath);
                        }

                        using (var fileStream = new FileStream(filePath, FileMode.Create))
                        {
                            file.CopyTo(fileStream);
                        }
                        fotorepo.Insert(new Photograph()
                        {
                            IssueId = issue.Id,
                            Path    = "/Uploads/" + 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 EmailModel()
                {
                    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"
                };
                _issuelogRepo.Insert(issueLog);

                return(RedirectToAction("Index", "Issue"));
            }
            catch (Exception ex)
            {
                var errorVM = new ErrorVM()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Create",
                    ControllerName = "Issue",
                    ErrorCode      = "500"
                };
                TempData["ErrorMessage"] = JsonConvert.SerializeObject(errorVM);
                return(RedirectToAction("Error500", "Home"));
            }
        }
Example #14
0
        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"));
            }
        }
Example #15
0
        public async Task <ActionResult> Details(string id)
        {
            //ViewBag.TechnicianList = await GetTechnicianList();

            var issue     = _issueRepo.GetById(id);
            var photoPath = _photoRepo.GetAll(x => x.IssueId == id).Select(y => y.Path).ToList();

            issue.PhotoPath = photoPath;

            if (issue == null)
            {
                TempData["Message2"] = "Arıza kaydı bulunamadi.";
                return(RedirectToAction("Index", "Operator"));
            }
            var user = await _membershipTools.UserManager.GetUserAsync(HttpContext.User);

            var userid = user.Id;

            if (userid == null)
            {
                return(RedirectToAction("Index", "Issue"));
            }

            var data = Mapper.Map <Issue, IssueVM>(issue);

            var techIds     = _issueRepo.GetAll(x => x.IssueState == IssueStates.İşlemde || x.IssueState == IssueStates.Atandı).Select(x => x.TechnicianId).ToList();
            var technicians = _membershipTools.UserManager.GetUsersInRoleAsync("Technician").Result;

            for (int i = 0; i < technicians.Count; i++)
            {
                var    distance       = 0.0;
                string distanceString = "";
                var    technician     = technicians[i];
                if (!techIds.Contains(technician.Id))
                {
                    if (technician.Latitude.HasValue && technician.Longitude.HasValue && data.Latitude.HasValue && data.Longitude.HasValue)
                    {
                        var issueCoordinate      = new GeoCoordinate(data.Latitude.Value, data.Longitude.Value);
                        var technicianCoordinate = new GeoCoordinate(technician.Latitude.Value, technician.Longitude.Value);

                        distance       = issueCoordinate.GetDistanceTo(technicianCoordinate) / 1000;
                        distanceString = $"(~{Convert.ToInt32(distance)} km)";
                    }

                    Technicians.Add(new SelectListItem()
                    {
                        Text  = technician.Name + " " + technician.Surname + " (" + await _membershipTools.GetTechPoint(user.Id) + ")" + distanceString,
                        Value = technician.Id
                    });
                }
                else
                {
                    continue;
                }
            }

            ViewBag.TechnicianList = Technicians;

            if (issue.OperatorId == null)
            {
                issue.OperatorId = userid;
                if (_issueRepo.Update(issue) > 0)
                {
                    issue.IssueState = IssueStates.KabulEdildi;
                    data.IssueState  = issue.IssueState;
                    _issueRepo.Update(issue);

                    var issueLog = new IssueLog()
                    {
                        IssueId     = issue.Id,
                        Description = "Operatör tarafından kabul edildi.",
                        FromWhom    = "Operatör"
                    };
                    _issueLogRepo.Insert(issueLog);

                    return(View(data));
                }
            }

            return(View(data));
        }
Example #16
0
 public void Complete(IssueLog issueLog)
 {
     _context.IssueLog.Update(issueLog);
     _context.SaveChanges();
 }
        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"));
            }
        }
Example #18
0
 public void Create(IssueLog issueLog)
 {
     _context.IssueLog.Add(issueLog);
     _context.SaveChanges();
 }