public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } LocationDetailsVM = await _context.Location.Select(l => new LocationDetailsViewModel() { LocationID = l.LocationID, LocationCode = l.LocationCode, DivisionName = l.Division.DivisionName, BusinessUnitName = l.BusinessUnit.BusinessUnitName, FirstAddress = l.Address.FirstAddress, SecondAddress = l.Address.SecondAddress, City = l.Address.City, StateProvince = l.Address.StateProvince, Country = l.Address.Country, PostalCode = l.Address.PostalCode, Lattitude = l.Address.Lattitude, Longitude = l.Address.Longitude }).FirstOrDefaultAsync(l => l.LocationID == id); if (LocationDetailsVM == null) { return(NotFound()); } return(Page()); }
public LocationDetailsPage(Location location) { InitializeComponent(); LocationDetailsViewModel vm = new LocationDetailsViewModel(location); this.BindingContext = vm; }
public static LocationDetailsViewModel ToDetailsViewModel(this Location source) { var destination = new LocationDetailsViewModel(); destination.Id = source.Id; destination.Name = source.Name; return(destination); }
public ActionResult LocationDetails(LocationDetailsViewModel model) { if (ModelState.IsValid) { Session[$"LocationDetailsInfo{Request.UserHostAddress}"] = model; return(RedirectToAction("Confirmation")); } return(View(model)); }
public static void ValidateLocationDetailsViewModel(LocationDetailsViewModel expected, LocationDetailsViewModel actual) { if (expected == null) { return; } Console.WriteLine(); Console.WriteLine("=== Validation: LocationDetailsViewModel ===\r\n"); Validate(expected.ID, actual.ID, TestAttribute.LocationID); Validate(expected.SelectedHeadEndCode, actual.SelectedHeadEndCode, "SelectedHeadEndCode"); if (expected.Address1 != null) { Validate(expected.Address1, actual.Address1, "Address1"); } if (expected.Address2 != null) { Validate(expected.Address2, actual.Address2, "Address2"); } if (expected.City != null) { Validate(expected.City, actual.City, TestAttribute.City); } if (expected.SelectedState != null) { Validate(expected.SelectedState, actual.SelectedState, "SelectedState"); } if (expected.ZIP != null) { Validate(expected.ZIP, actual.ZIP, "ZIP"); } if (expected.ZIPPlusFourCode != null) { Validate(expected.ZIPPlusFourCode, actual.ZIPPlusFourCode, "ZIPPlusFourCode"); } if (expected.FacilityList != null) { ValidateFacility(expected.FacilityList, actual.FacilityList); } if (expected.CustomField != null) { ValidateCustomFields(expected.CustomField, actual.CustomField); } if (expected.oldLocID != null) { Validate(expected.oldLocID, actual.oldLocID, "oldLocID"); } Console.WriteLine("==========================="); }
/// <summary> /// Creates new location details page /// </summary> /// <param name="location">location to display</param> public LocationDetailsPage(Location location) { this.Title = "Location details"; this.InitializeComponent(); this.BindingContext = this.viewModel = new LocationDetailsViewModel(App.Settings, location); if (location.Type == LocationType.LiveWaypoint) { this.AddLiveWaypointRefreshToolbarButton(); } if (location.IsPlanTourLocation) { this.AddTourPlanLocationToolbarButton(); } }
public static LocationDetailsViewModel LocDetailsViewModel(Location loc) { var data = new LocationDetailsViewModel { Address1 = loc.AddressLine1, Address2 = loc.AddressLine2, City = loc.CityName, CustomField = loc.CustomFields, ID = loc.ID, SelectedHeadEndCode = loc.HeadendCode, State = loc.StateName, ZIP = loc.ZipCode, FacilityList = loc.FacilityList, ZIPPlusFourCode = loc.ZipPlusFourCode, //oldLocID = loc.ID }; return data; }
public IActionResult Details(int id, string name) { TempData["locationId"] = id.ToString(); //Package package = _packageDataService.GetSingle(p => p.PackageId == id); //TempData["locationName"] = name; Location location = _locationDataService.GetSingle(p => p.LocationId == id); IEnumerable <Package> packageList = _packageDataService.Query(p => p.LocationId == id && p.IsAvailable == true); LocationDetailsViewModel vm = new LocationDetailsViewModel { Name = location.Name, Description = location.Description, Picture = location.Picture, Packages = packageList }; return(View(vm)); }
// GET: Movies/Details/5 public IActionResult Details(int?id) { if (id == null) { return(NotFound()); } var location = _unitOfWork.Locations.Get(id.Value); if (location == null) { return(NotFound()); } var inventories = _unitOfWork.Inventories.GetLocationInventory(id.Value); var locationDetailsVM = new LocationDetailsViewModel { Loc = location, FilteredInventory = inventories.ToList() }; return(View(locationDetailsVM)); }
public ActionResult Details(int ID, string SearchText, int?LocationGroupID) { try { REF_LOCATION_TB location = _uow.Repository <REF_LOCATION_TB>().GetById(ID); LocationDetailsViewModel model = new LocationDetailsViewModel() { Description = location.SZ_DESCRIPTION, EffectiveDate = location.DT_EFFECTIVE == null ? "" : location.DT_EFFECTIVE.Value.ToShortDateString(), ExpiredDate = location.DT_EXPIRED == null ? "" : location.DT_EXPIRED.Value.ToShortDateString(), LocationGroupID = Convert.ToInt32(LocationGroupID), LocationID = ID, SearchText = SearchText, Station = location.SZ_LABEL, XCoordinate = location.N_GIS_X.ToString(), YCoordinate = location.N_GIS_Y.ToString(), OrderUpDown = location.SZ_STREAM_NUMBER }; return(View(model)); } catch (Exception ex) { if (ex.InnerException == null) { ViewBag.Message = "Function: LocationController.Details_GET\n\nError: " + ex.Message; } else { ViewBag.Message = "Function: LocationController.Details_GET\n\nError: " + (ex.Message + "\n\nInnerException: " + ex.InnerException.Message); }; Session["ErrorMessage"] = ViewBag.Message; return(RedirectToAction("InternalServerError", "Error")); }; }
public IActionResult Details(int id) { LocationDetailsViewModel locationDetailsViewModel = LocationDetailsViewModel.GetLocationDetailsViewModel(context, id); return(View(locationDetailsViewModel)); }
public IActionResult Details(int LocationId) { List <LocationDetailsViewModel> location = LocationDetailsViewModel.GetLocationDetails(repositoryFactory); return(View(location)); }
public async Task <IActionResult> Details(string name, string sorting) { IEnumerable <Package> list = _packageService.GetAll(); Location loc = _locationService.GetSingle(l => l.Name == name); if (loc != null) { TempData["locId"] = loc.LocationId.ToString(); List <Package> packageList; switch (sorting) { case "hight": packageList = list.Where(p => p.LocationId == loc.LocationId).Where(p => p.Active).OrderByDescending(x => x.Price).ToList(); break; case "low": packageList = list.Where(p => p.LocationId == loc.LocationId).Where(p => p.Active).OrderBy(x => x.Price).ToList(); break; default: packageList = list.Where(p => p.LocationId == loc.LocationId).Where(p => p.Active).ToList(); break; } LocationDetailsViewModel vm = new LocationDetailsViewModel { LocationId = loc.LocationId, Name = loc.Name, Details = loc.Details, TotalPackages = packageList.Count(), Packages = packageList, Picture = loc.Picture }; if (User.Identity.IsAuthenticated && User.IsInRole("Provider")) { IdentityUser user = await _userManagerService.FindByNameAsync(User.Identity.Name); vm.UnactivePackages = list.Where(p => p.LocationId == loc.LocationId).Where(p => p.UserId == user.Id).Where(p => !p.Active); vm.TotalUnactivePac = list.Where(p => p.LocationId == loc.LocationId).Where(p => p.UserId == user.Id).Count(p => !p.Active); } return(View(vm)); } else { List <Package> packageList; switch (sorting) { case "hight": packageList = _packageService.GetAll().Where(p => p.Active).OrderByDescending(x => x.Price).ToList(); break; case "low": packageList = _packageService.GetAll().Where(p => p.Active).OrderBy(x => x.Price).ToList(); break; default: packageList = _packageService.GetAll().Where(p => p.Active).ToList(); break; } LocationDetailsViewModel vm = new LocationDetailsViewModel { TotalPackages = packageList.Count, Packages = packageList }; if (User.Identity.IsAuthenticated && User.IsInRole("Provider")) { IdentityUser user = await _userManagerService.FindByNameAsync(User.Identity.Name); vm.UnactivePackages = list.Where(p => p.UserId == user.Id).Where(p => !p.Active); vm.TotalUnactivePac = list.Where(p => p.UserId == user.Id).Count(p => !p.Active); } return(View(vm)); } }
public IActionResult Details(LocationDetailsViewModel vm) { return(RedirectToAction("Details", "Location", new { name = vm.Search })); }
public async Task <ActionResult> Confirmation() { string RoleName = ""; AccountDetailsViewModel AccountDetails = Session[$"AccountDetailsInfo{Request.UserHostAddress}"] as AccountDetailsViewModel; LocationDetailsViewModel LocationDetails = Session[$"LocationDetailsInfo{Request.UserHostAddress}"] as LocationDetailsViewModel; var user = new ApplicationUser { UserName = AccountDetails.Username, Email = AccountDetails.Email, IsManager = AccountDetails.IsRetailer, FirstName = AccountDetails.FirstName, LastName = AccountDetails.LastName }; var result = await UserManager.CreateAsync(user, AccountDetails.Password); if (result.Succeeded) { if (AccountDetails.IsRetailer) { Store NewlyCreatedStore = StoreRepo.Add(new Store() { Name = LocationDetails.StoreName, Address = LocationDetails.Address, City = LocationDetails.City, State = LocationDetails.State, Area = LocationDetails.Area, }); user.StoreId = NewlyCreatedStore.Id; RoleName = "admin"; } else { user.City = LocationDetails.City; user.State = LocationDetails.State; user.Area = LocationDetails.Area; user.Address = LocationDetails.Address; RoleName = "customer"; } var result1 = await UserManager.UpdateAsync(user); var User = UserManager.FindByEmail(user.Email); if (!UserManager.IsInRole(User.Id, RoleName)) { UserManager.AddToRole(User.Id, RoleName); } await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : true); if (!UserManager.IsInRole(User.Id, "admin")) { return(RedirectToAction("Index", "Products", new { Area = "Managers" })); } else { return(RedirectToAction("Index", "CustomerHome", new { Area = "Customers" })); } } if (!result.Succeeded) { string ErrorMesages = ""; foreach (var item in result.Errors) { ErrorMesages += "\n" + item; } throw new Exception(ErrorMesages); } return(View()); }
public LocationDetailsPage() { InitializeComponent(); BindingContext = vm = ViewModelLocator.Details; }