// Google Maps Embeded Api, No Long used, but kept for easy use/reference. public IActionResult AddressMap(int id) { // Removed Secret, may require API request below to be adjusted for key + query. string key = "*INSERT API KEY"; Customer customer = _context.Customers.Where(c => c.Id == id).SingleOrDefault(); var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var employee = _context.Employees.Where(c => c.IdentityUserId == userId).SingleOrDefault(); string query; string googleMapsApiUrlRequest; //Html encode (spaces, periods, etc) try { //mapUrl = await GetGoogleMapsApiUrl(customer); query = HttpUtility.UrlEncode(customer.StreetAddress + "," + customer.City + "," + customer.ZipCode); googleMapsApiUrlRequest = "https://www.google.com/maps/embed/v1/place?" + key + query; } catch { // Todo: Call error log. EmployeesIndexViewModel employeesIndexView = new EmployeesIndexViewModel(employee, _context, "Pickup Confirmation Failed!"); return(View("Index", employeesIndexView)); } employee.Addresses = new Dictionary <string, string>(); employee.Addresses.Add($"{customer.FamilyName} residence: {customer.StreetAddress}, {customer.City}, {customer.ZipCode}", googleMapsApiUrlRequest); return(View(employee)); }
public ActionResult Index() { //var employees = _empRepo.GetList(); var viewModel = new EmployeesIndexViewModel() { Employees = _empRepo.GetList() }; return(View(viewModel)); }
public IActionResult PickupCompleted(int id) { //var completedPickupInDb = _context.OneTimePickups.Where(o => o.Id == completedPickup.Id).Single(); var completedPickupInDb = _context.OneTimePickups.Where(o => o.Id == id).Single(); try { //var completedPickupInDb = _context.OneTimePickups.Find(completedPickup); var customer = _context.Customers.Where(c => c.Id == completedPickupInDb.CustomerId).FirstOrDefault(); customer.SpecialtyPickupCompleted = true; double pickupFee = TrashPrices.GetOneTimePickupCost(customer); customer.OutstandingBalance += pickupFee; AccountTransaction serviceFee = new AccountTransaction(); serviceFee.CustomerId = customer.Id; serviceFee.Fee = pickupFee; serviceFee.TransactionDate = DateTime.Today; serviceFee.TransactionType = "Specialty Pickup"; customer.SpecialtyPickupDay = DateTime.MinValue; completedPickupInDb.HasBeenPickedup = true; _context.AccountTransactions.Add(serviceFee); _context.SaveChanges(); var employee = _context.Employees.Where(e => e.Id == completedPickupInDb.EmployeeId).SingleOrDefault(); var addresses = _context.Customers.Where(c => c.ZipCode == employee.AssignedZipCode).ToDictionary(c => c.StreetAddress, c => c.WeeklyPickupDay); employee.Addresses = addresses; EmployeesIndexViewModel employeesIndexView = new EmployeesIndexViewModel(employee, _context, "Pickup Confirmation Recieved."); //return View("Index", employeesIndexView); return(Index("Pickup Confirmation Recieved.")); } catch { //completedPickupInDb = _context.OneTimePickups.Where(o => o == (OneTimePickup)completedPickup).Single(); var employee = _context.Employees.Where(e => e.Id == completedPickupInDb.EmployeeId).SingleOrDefault(); var addresses = _context.Customers.Where(c => c.ZipCode == employee.AssignedZipCode).ToDictionary(c => c.StreetAddress, c => c.WeeklyPickupDay); employee.Addresses = addresses; EmployeesIndexViewModel employeesIndexView = new EmployeesIndexViewModel(employee, _context, "Pickup Confirmation Failed!"); return(View("Index", employeesIndexView)); } }
public IActionResult Index(string message) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var employee = _context.Employees.Where(c => c.IdentityUserId == userId).SingleOrDefault(); if (employee == null) { return(RedirectToAction("FinishRegistration")); } employee.Addresses = _context.Customers.Where(c => c.ZipCode == employee.AssignedZipCode).ToDictionary(c => c.StreetAddress, c => c.WeeklyPickupDay); EmployeesIndexViewModel employeeIndexViewModel = new EmployeesIndexViewModel(employee, _context); return(View(employeeIndexViewModel)); }
// GET: Employees public ActionResult Index() { //ログインユーザーID取得 string UserId = User.Identity.GetUserId(); //フォロー先ユーザーList作成 List <string> myFollows = db.Follows .Where(r => r.EmployeeId == UserId) .Select(r => r.FollowId) .ToList(); // ビューに送るためのEmployeesIndexViewModelのリストを作成 List <EmployeesIndexViewModel> indexViewModel = new List <EmployeesIndexViewModel>(); // ユーザー一覧を、作成日時が最近のものから順にしてリストとして取得 List <ApplicationUser> users = db.Users.OrderByDescending(u => u.CreatedAt).ToList(); // ユーザーのリストを、EmployeesIndexViewModelのリストに変換 foreach (ApplicationUser applicationUser in users) { // EmployeesIndexViewModelをApplicationUserから必要なプロパティだけ抜き出して作成 EmployeesIndexViewModel employee = new EmployeesIndexViewModel { Email = applicationUser.Email, EmployeeName = applicationUser.EmployeeName, DeleteFlg = applicationUser.DeleteFlg, Id = applicationUser.Id }; //フォローボタン制御 if (applicationUser.Id == UserId) //ログインユーザー自身 { employee.FollowStatusFlag = FollowStatusEnum.LoginUser; } else if (myFollows.Contains(employee.Id)) //フォロー済み { employee.FollowStatusFlag = FollowStatusEnum.Following; } else //未フォロー { employee.FollowStatusFlag = FollowStatusEnum.Unfollowed; } // 作成したEmployeesIndexViewModelをリストに追加 indexViewModel.Add(employee); } // 作成したリストをIndexビューに送る return(View(indexViewModel)); }
public IActionResult FinishRegistration(Employee employee) { try { employee.IdentityUserId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); employee.EmailAddress = this.User.FindFirstValue(ClaimTypes.Name); _context.Add(employee); _context.SaveChanges(); EmployeesIndexViewModel employeeIndexViewModel = new EmployeesIndexViewModel(employee, _context, "Registration Complete"); return(View("Index", employeeIndexViewModel)); } catch { return(View()); } }
// GET: Employees public ActionResult Index() { //ビューに送る為のEmployeesIndexViewModelのリストを作成 List <EmployeesIndexViewModel> employees = new List <EmployeesIndexViewModel>(); //ユーザ一覧を、作成日時が最近のものから順にしてリストとして取得 List <ApplicationUser> users = db.Users.OrderByDescending(u => u.CreatedAt).ToList(); //ユーザのリストをEmployeeIndexViewModelのリストに変換 foreach (ApplicationUser applicationUser in users) { //EmployeeIndexViewModelをApplicationUsersから必要なプロパティだけ抜き出して作成 EmployeesIndexViewModel employee = new EmployeesIndexViewModel { Email = applicationUser.Email, EmployeeName = applicationUser.EmployeeName, DeleteFlg = applicationUser.DeleteFlg, Id = applicationUser.Id }; //作成したEmployeesIndexViewModelをリストに追加 employees.Add(employee); } //作成したリストをIndexビューに送る return(View(employees)); }
// GET: Employees public async Task <IActionResult> Index( string sortOrder, string role, string searchString, int?pageNumber) { // Use LINQ to get list of role. IQueryable <string> roleQuery = _roleManager.Roles.Select(r => r.Name).Where(n => n != "Customer"); var employees = _context.Employees.Select(e => e); if (!string.IsNullOrEmpty(searchString)) { employees = employees.Where(e => e.FullName.Contains(searchString) || e.Email.Contains(searchString) || e.Id.Contains(searchString)); } ViewBag.FirstNameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.SalarySortParm = sortOrder == "price_asc" ? "price_desc" : "price_asc"; switch (sortOrder) { case "name_desc": employees = employees.OrderByDescending(s => s.FirstName); break; case "price_asc": employees = employees.OrderBy(s => s.Salary); break; case "price_desc": employees = employees.OrderByDescending(s => s.Salary); break; default: employees = employees.OrderBy(s => s.FirstName); break; } var employeesInRole = new List <SportsStore.Models.Employee>(); if (!string.IsNullOrEmpty(role)) { foreach (var employee in employees.ToList()) { if (await _userManager.IsInRoleAsync(employee, role)) { employeesInRole.Add(employee); } } } else { employeesInRole = employees.ToList(); } int pageSize = 3; var model = new EmployeesIndexViewModel() { Employees = PaginatedList <SportsStore.Models.Employee> .Create(employeesInRole, pageNumber ?? 1, pageSize), Role = !string.IsNullOrEmpty(role) ? role : "All", SearchString = searchString, SortOrder = sortOrder, Roles = await roleQuery.Distinct().ToListAsync() }; return(View(model)); }