Ejemplo n.º 1
0
        protected async Task <List <SelectListItem> > GetTechnicianList()
        {
            var data        = new List <SelectListItem>();
            var userManager = _membershipTools.UserManager;

            var users = userManager.Users.ToList();

            var techIds = _issueRepo.GetAll(x => x.IssueState == IssueStates.İşlemde || x.IssueState == IssueStates.Atandı).Select(x => x.TechnicianId).ToList();

            foreach (var user in users)
            {
                if (await userManager.IsInRoleAsync(user, IdentityRoles.Technician.ToString()))
                {
                    if (!techIds.Contains(user.Id))
                    {
                        data.Add(new SelectListItem()
                        {
                            Text  = $"{user.Name} {user.Surname} ({await _membershipTools.GetTechPoint(user.Id)})",
                            Value = user.Id
                        });
                    }
                }
            }
            return(data);
        }
Ejemplo n.º 2
0
        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
                }));
            }
        }
Ejemplo n.º 3
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));
        }