public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index", "Home")); } int packageId = id.GetValueOrDefault(); PackagesViewModel model = new PackagesViewModel(); Result <Package> packageResult = new Result <Package>(); packageResult = packageService.GetPackageById(packageId); if (packageResult.Status == ResultEnum.Success && WebSecurity.CurrentUserId == packageResult.Data.ApplicationUserId && packageResult.Data.Status == PackageStatusEnum.Available) { model = packageResult.Data.ToPackagesViewModel(); } else { return(RedirectToAction("Index", "Home")); } return(View(model)); }
public AddPackagesDialog ( ManagePackagesViewModel parentViewModel, string initialSearch, IBackgroundPackageActionRunner backgroundActionRunner, IRecentPackageRepository recentPackageRepository) { this.parentViewModel = parentViewModel; this.viewModel = parentViewModel.AvailablePackagesViewModel; this.backgroundActionRunner = backgroundActionRunner; this.recentPackageRepository = recentPackageRepository; Build (); UpdatePackageSearchEntryWithInitialText (initialSearch); InitializeListView (); UpdateAddPackagesButton (); ShowLoadingMessage (); LoadViewModel (initialSearch); this.showPrereleaseCheckBox.Clicked += ShowPrereleaseCheckBoxClicked; this.packageSourceComboBox.SelectionChanged += PackageSourceChanged; this.addPackagesButton.Clicked += AddPackagesButtonClicked; this.packageSearchEntry.Changed += PackageSearchEntryChanged; this.packageSearchEntry.Activated += PackageSearchEntryActivated; imageLoader.Loaded += ImageLoaded; }
public async Task <IActionResult> Index() { if (!this.User.Identity.IsAuthenticated) { return(this.View()); } var user = await this.userManager.GetUserAsync(this.User); var pendingPackages = this.packageService.GetUserPendingPackages(user); var shippedPackages = this.packageService.GetUserShippedPackages(user); var deliveredPackages = this.packageService.GetUserDeliveredPackages(user); this.ViewBag.Username = user.UserName; var packages = new PackagesViewModel() { PendingPackages = pendingPackages, ShippedPackages = shippedPackages, DeliveredPackages = deliveredPackages }; return(View(packages)); }
public async Task <ActionResult> Packages(PackagesViewModel model) { await Init(); try { var client = new HttpClient { Timeout = TimeSpan.FromSeconds(10) }; var clientsJSON = await client.GetStringAsync("https://coderrapp.com/configure/packages/"); model.Packages = JsonConvert.DeserializeObject <NugetPackage[]>(clientsJSON); } catch (Exception) { model.ErrorMessage = "Failed to download package information"; } if (string.IsNullOrEmpty(model.LibraryName)) { ModelState.AddModelError("LibraryName", "A package must be selected"); return(View(model)); } return(RedirectToAction("ConfigurePackage", new { model.LibraryName, model.ApplicationId })); }
public IHttpResponse Index() { if (this.User.IsLoggedIn) { var products = this.Db.Packages .Where(p => p.Recipient.Username == this.User.Username) .Select(p => new PackageViewModel { Id = p.Id, Name = p.Description, Status = p.Status.ToString() }).ToList(); var view = new PackagesViewModel { Shipped = products.Where(p => p.Status == "Shipped").ToList(), Pending = products.Where(p => p.Status == "Pending").ToList(), Delivered = products.Where(p => p.Status == "Delivered").ToList(), }; return(this.View("Home/LoggedInIndex", view)); } else { return(this.View()); } }
public void Reset() { if (IsQueryCompleted) { _packagesViewModel = null; IsQuerying = false; PackagesInFeeds.Clear(); _marks.Clear(); } }
public PackagesForSelectedPageQuery ( PackagesViewModel viewModel, IEnumerable<IPackage> allPackages, string searchCriteria) { Skip = viewModel.ItemsBeforeFirstPage; Take = viewModel.PageSize; AllPackages = allPackages; SearchCriteria = new PackageSearchCriteria (searchCriteria); TotalPackages = viewModel.TotalItems; }
public async Task <IActionResult> Packages() { ViewBag.ActivePage = "Packages"; var user = await userManager.FindByNameAsync(User.Identity.Name); var userPackages = await userRepository.GetUserpackages(user.UserName); PackagesViewModel model = new PackagesViewModel(); model.Declarations = userPackages.Declarations; return(View(model)); }
public ActionResult Add() { PackagesViewModel model = new PackagesViewModel(); if (MvcApplication.SHOW_SAMPLE_FORM_DATA) { // Show dummy user data for model model = SampleModelData.GetSamplePackagesViewModel(); } return(View(model)); }
public ActionResult Add(PackagesViewModel model) { if (model.ImageUpload == null || model.ImageUpload.ContentLength == 0) { ModelState.AddModelError("ErrorMessage", "The image field is required."); return(View(model)); } if (ModelState.IsValid) { // Process image string[] validImageTypes = new string[] { "image/gif", "image/jpeg", "image/pjpeg", "image/png" }; if (!validImageTypes.Contains(model.ImageUpload.ContentType)) { ModelState.AddModelError("ErrorMessage", "Please choose either a GIF, JPG or PNG image."); return(View(model)); } string uploadDir = @"~/Images/Packages"; string imagePath = Path.Combine(Server.MapPath(uploadDir), model.ImageUpload.FileName); string imageUrl = Path.Combine(uploadDir, model.ImageUpload.FileName); model.ImageUpload.SaveAs(imagePath); Package package = model.ToPackage(); package.ImageUrl = imageUrl; package.Status = PackageStatusEnum.Available; package.ApplicationUserId = WebSecurity.CurrentUserId; Result <Package> result = packageService.AddPackage(package); if (result.Status == ResultEnum.Success) { return(RedirectToAction("Add", "Activities", new { packageId = result.Data.PackageId })); } else { ModelState.AddModelError("ErrorMessage", "Sorry, we were unable to create your package."); model.DisableSubmit = true; return(View(model)); } } ModelState.AddModelError("ErrorMessage", "Sorry, we were unable to create your package."); model.DisableSubmit = true; return(View(model)); }
public static Package ToPackage(this PackagesViewModel model) { return(new Package { Accomodation = model.Accomodation, City = model.City, ImageUrl = model.ImageUrl, Name = model.PackageName, Amount = model.Price, State = model.State, }); }
public override void Execute(object parameter) { var userControl = new PackagesUserControl(); var viewModel = new PackagesViewModel(); viewModel.PackageModels = _packageManager.GetModels(); userControl.DataContext = viewModel; _mainViewModel.Grid.Children.Clear(); _mainViewModel.Grid.Children.Add(userControl); }
public IHttpResponse Index() { var user = this.db.Users.FirstOrDefault(u => u.Username == this.User.Username); if (user != null) { var pendingPackages = this.db.Packages .Where(r => r.Recipient.Username == user.Username && r.Status == Status.Pending) .Select(p => new PackageViewModel { Id = p.Id, Description = p.Description }) .ToList(); var shippedPackages = this.db.Packages .Where(r => r.Recipient.Username == user.Username && r.Status == Status.Shipped) .Select(p => new PackageViewModel { Id = p.Id, Description = p.Description }) .ToList(); var deliveredPackages = this.db.Packages .Where(r => r.Recipient.Username == user.Username && r.Status == Status.Delivered) .Select(p => new PackageViewModel { Id = p.Id, Description = p.Description }) .ToList(); var packagesViewModel = new PackagesViewModel { PendingPackages = pendingPackages, ShippedPackages = shippedPackages, DeliveredPackages = deliveredPackages }; return(this.View("/Home/IndexLoggedIn", packagesViewModel)); } return(this.View()); }
public HttpResponse Delivered() { if (!this.IsUserLoggedIn()) { return(this.Redirect("/Users/Login")); } var viewModel = new PackagesViewModel { Packages = this.packagesService .GetAllByStatus(PackageStatus.Delivered) }; return(this.View(viewModel)); }
public ActionResult Edit(PackagesViewModel model) { if (ModelState.IsValid) { Result <Package> packageResult = new Result <Package>(); packageResult = packageService.GetPackageById(model.Id); Package package = new Package(); if (packageResult.Status == ResultEnum.Success && packageResult.Data.Status == PackageStatusEnum.Available) { package = packageResult.Data; package.City = model.City; package.State = model.State; package.Accomodation = model.Accomodation; package.Amount = model.Price; } else { model.ErrorMessage = "Unable to edit the package."; return(View(model)); } ResultEnum result = packageService.UpdatePackage(package); if (result == ResultEnum.Success) { model.SuccessMessage = "Package successfully edited."; } else { model.ErrorMessage = "Unable to edit the package."; } return(View(model)); } model.ErrorMessage = "Unable to edit the package."; return(View(model)); }
/// <summary> /// Inicializacion de todos los objetos necesarios para el funcionamiento correcto del formulario /// </summary> public void startObjects() { _LiquHdVM = new Liquidation_HdrViewModel(); /// _CoordinatorVM = new CoordinatorViewModel(); /// _TransGuidesVM = new Transporters_GuidesViewModel(); /// _packagesVM = new PackagesViewModel(); /// _packDtlVM = new Packages_DtlViewModel(); /// _ocPackDtl = new ObservableCollection <Packages_Dtl>(); /// _CustomerType = ""; /// //objGenerarTicket = new GenerarTicket(); /// ///GridLiqInfo.DataContext = _LiquHdVM.getLiquidationHdr(_co, "25085"); /// }
public async Task <ActionResult> Packages(int?applicationId, string appKey) { await Init(); if (applicationId == null) { try { var appInfo = await _queryBus.QueryAsync(this.ClaimsUser(), new GetApplicationInfo(appKey)); applicationId = appInfo.Id; } catch (EntityNotFoundException) { await Task.Delay(1000); return(RedirectToAction("Packages", new { appKey })); } } var model = new PackagesViewModel { ApplicationId = applicationId.Value }; try { var client = new HttpClient { Timeout = TimeSpan.FromSeconds(10) }; var clientsJSON = await client.GetStringAsync("https://coderrapp.com/configure/packages/"); model.Packages = JsonConvert.DeserializeObject <NugetPackage[]>(clientsJSON); } catch (Exception) { model.ErrorMessage = "Failed to download package information"; } return(View(model)); }
public AddPackagesDialog( AvailablePackagesViewModel viewModel, string title, string initialSearch = null) { this.viewModel = viewModel; Build (); Title = title; UpdatePackageSearchEntryWithInitialText (initialSearch); InitializeListView (); UpdateAddPackagesButton (); ShowLoadingMessage (); LoadViewModel (initialSearch); this.showPrereleaseCheckBox.Clicked += ShowPrereleaseCheckBoxClicked; this.packageSourceComboBox.SelectionChanged += PackageSourceChanged; this.addPackagesButton.Clicked += AddPackagesButtonClicked; this.packageSearchEntry.Changed += PackageSearchEntryChanged; this.packageSearchEntry.Activated += PackageSearchEntryActivated; imageLoader.Loaded += ImageLoaded; }
public void LoadViewModel(PackagesViewModel viewModel) { this.viewModel = viewModel; this.includePrereleaseCheckButton.Visible = viewModel.ShowPrerelease; this.packageSearchHBox.Visible = viewModel.IsSearchable; ClearSelectedPackageInformation (); PopulatePackageSources (); viewModel.PropertyChanged += ViewModelPropertyChanged; this.pagedResultsWidget.LoadPackagesViewModel (viewModel); this.pagedResultsHBox.Visible = viewModel.IsPaged; this.updateAllPackagesButtonBox.Visible = viewModel.IsUpdateAllPackagesEnabled; }
public BasePackageCommand(PackagesViewModel viewModel, PackageManager packageManager) { _packageViewModel = viewModel; _pacakgeManager = packageManager; }
public OpenEditPackageViewCommand(PackagesViewModel packagesViewModel, PackageManager packageManager) : base(packagesViewModel, packageManager) { }
protected override void Dispose (bool disposing) { imageLoader.Loaded -= ImageLoaded; imageLoader.Dispose (); viewModel.PropertyChanged -= ViewModelPropertyChanged; parentViewModel.Dispose (); DisposeExistingTimer (); packageStore.Clear (); viewModel = null; parentViewModel = null; base.Dispose (disposing); }
public void LoadViewModel(PackagesViewModel viewModel) { this.viewModel = viewModel; this.packageSearchHBox.Visible = viewModel.IsSearchable; ClearSelectedPackageInformation (); PopulatePackageSources (); viewModel.PropertyChanged += ViewModelPropertyChanged; }
private void FacilitySubscriptions_OnClosing(object sender, CancelEventArgs e) { PackagesViewModel.CleanUp(); }
public void LoadPackagesViewModel (PackagesViewModel viewModel) { this.viewModel = viewModel; this.viewModel.PropertyChanged += ViewModelPropertyChanged; }
public DeletePackageCommand(PackagesViewModel viewModel, PackageManager packageManager) : base(viewModel, packageManager) { }
public OpenSavePackageViewCommand(PackagesViewModel viewModel, PackageManager packageManager) : base(viewModel, packageManager) { }