////   GET: /Inventory/Package/CreatePackage
        public JsonResult CreatePackageDetails(PackageDetailsViewModel packageData, List <ProductPackageVM> productList)
        {
            // return null;
            var data = _aManager.CreatePackageDetails(packageData, productList);

            return(Json(new { success = data.Status, data }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public IActionResult Details(string id)
        {
            Package package = this.db.Packages
                              .Include(x => x.Recipient)
                              .Include(x => x.Status)
                              .SingleOrDefault(x => x.Id == id);

            PackageDetailsViewModel viewModel = new PackageDetailsViewModel
            {
                Description     = package.Description,
                Recipient       = package.Recipient.UserName,
                ShippingAddress = package.ShippingAddress,
                Weight          = package.Weight,
                Status          = package.Status.Name
            };

            if (package.Status.Name == "Pending")
            {
                viewModel.EstimatedDeliveryDate = "N/A";
            }
            else if (package.Status.Name == "Shipped")
            {
                viewModel.EstimatedDeliveryDate = package.EstimatedDeliveryDate.ToString("dd/MM/YYYY", CultureInfo.InvariantCulture);
            }
            else
            {
                viewModel.EstimatedDeliveryDate = "Delivered";
            }

            return(this.View(viewModel));
        }
Exemplo n.º 3
0
        public IActionResult Details(int id)
        {
            Package currentPackage = _packageRepo.GetSingle(p => p.PackageId == id);

            IEnumerable <Feedback> packageFeedbacks = _feedbackRepo.Query(f => f.PackageId == currentPackage.PackageId);

            double packageRating         = 0;
            int    packageFeedbackNumber = 0;

            if (packageFeedbacks.Count() > 0)
            {
                packageRating         = packageFeedbacks.Average(f => f.Rating);
                packageFeedbackNumber = packageFeedbacks.Count();
            }

            PackageDetailsViewModel vm = new PackageDetailsViewModel
            {
                ProviderId      = currentPackage.ProviderId,
                PackageId       = currentPackage.PackageId,
                Name            = currentPackage.Name,
                CompanyName     = _providerRepo.GetSingle(p => p.ProviderId == currentPackage.ProviderId).DisplayName,
                Rating          = packageRating,
                NumberOfReviews = packageFeedbackNumber,
                Location        = currentPackage.Location,
                Description     = currentPackage.Description,
                ThumbnailUrl    = currentPackage.ThumbnailUrl,
                Price           = currentPackage.Price,
                Feedbacks       = packageFeedbacks
            };

            return(View(vm));
        }
Exemplo n.º 4
0
        public static PackageDetailsViewModel ToDetailsViewModel(this Package source)
        {
            var destination = new PackageDetailsViewModel();

            destination.BookingId = source.BookingId;

            destination.Description         = source.Description;
            destination.Pieces              = source.Pieces;
            destination.Weight              = source.Weight;
            destination.SpecialInstructions = source.SpecialInstructions;

            destination.TrackingNumber  = source.TrackingNumber;
            destination.ReferenceNumber = source.ReferenceNumber;
            destination.PickedUpAt      = source.PickedUpAt;
            destination.DeliveredAt     = source.DeliveredAt;
            destination.AssignedTo      = source.AssignedTo != null ? source.AssignedTo.UserName : string.Empty;
            destination.DeliveredBy     = source.DeliveredBy != null ? source.DeliveredBy.UserName : string.Empty;
            destination.Status          = source.Status.ToString();

            if (source.PackageType != null)
            {
                destination.PackageType = source.PackageType.ToDetailsViewModel();
            }

            if (source.PackageLogs != null)
            {
                destination.PackageLogs = source.PackageLogs.ToList().ToListViewModel();
            }

            return(destination);
        }
Exemplo n.º 5
0
        public IHttpResponse Details(int id)
        {
            var dbPackage = this.Db.Packages
                            .Include(p => p.Recipient)
                            .FirstOrDefault(p => p.Id == id);

            string date;

            if (dbPackage.Status == Status.Pending)
            {
                date = "N/A";
            }
            else if (dbPackage.Status == Status.Shipped)
            {
                date = dbPackage.EstimatedDeliveryDate.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                date = "Delivered";
            }

            var model = new PackageDetailsViewModel
            {
                Description           = dbPackage.Description,
                EstimatedDeliveryDate = date,
                Status          = dbPackage.Status.ToString(),
                Recipient       = dbPackage.Recipient.Username,
                ShippingAddress = dbPackage.ShippingAddress,
                Weight          = dbPackage.Weight
            };

            return(this.View(model));
        }
Exemplo n.º 6
0
        public IActionResult Details(string id)
        {
            var package = this.packageService.GetPackage(id);

            string deliveryDate = null;

            if (package.EstimatedDeliveryDate == null || package.Status == PackageStatus.Delivered)
            {
                deliveryDate = "N/A";
            }
            else if (package.Status == PackageStatus.Acquired)
            {
                deliveryDate = "Delivered";
            }
            else
            {
                deliveryDate = package.EstimatedDeliveryDate.Value.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
            }

            var packageViewModel = new PackageDetailsViewModel()
            {
                Description           = package.Description,
                Address               = package.ShippingAddress,
                EstimatedDeliveryDate = deliveryDate,
                Recipient             = package.Recipient.UserName,
                Status = package.Status.ToString(),
                Weight = package.Weight
            };

            return(this.View(packageViewModel));
        }
        public StarTransitMainWindow(PackageModel package)
        {
            InitializeComponent();

            _package = package;
            var packageDetailsViewModel = new PackageDetailsViewModel(package, this);

            _packageDetails = new PackageDetails(packageDetailsViewModel);

            _translationMemories = new TranslationMemories();

            finishViewModel = new FinishViewModel(packageDetailsViewModel);
            _finish         = new Finish(finishViewModel);

            var starTransitViewModel = new StarTransitMainWindowViewModel(packageDetailsViewModel
                                                                          , _packageDetails
                                                                          , _translationMemories
                                                                          , finishViewModel);

            DataContext = starTransitViewModel;
            if (starTransitViewModel.CloseAction == null)
            {
                starTransitViewModel.CloseAction = Close;
            }
        }
Exemplo n.º 8
0
        public IHttpResponse Details(int id)
        {
            var receipt = this.Db.Receipts.FirstOrDefault(x => x.Id == id);

            if (receipt == null)
            {
                return(this.BadRequestError("Invalid receipt"));
            }

            if (receipt.Recipient.Username != this.User.Username)
            {
                return(this.Redirect("/"));
            }

            var packageFromDb = this.Db.Packages.FirstOrDefault(x => x.Id == receipt.PackageId);

            var packageViewModel = new PackageDetailsViewModel
            {
                Address     = packageFromDb.ShippingAddress,
                Description = packageFromDb.Description,
                Recipient   = packageFromDb.Recipient.Username,
                Weight      = packageFromDb.Weight
            };

            var receiptViewModel = new DetailsReceiptViewModel
            {
                Id       = receipt.Id,
                Fee      = receipt.Fee,
                IssuedOn = receipt.IssuedOn.ToString(),
                Package  = packageViewModel
            };

            return(this.View(receiptViewModel));
        }
        public StarTransitMainWindow(PackageModel package)
        {
            InitializeComponent();

            IMessageBoxService messageBoxService = new MessageBoxService();
            var packageDetailsViewModel          = new PackageDetailsViewModel(package, messageBoxService);

            _packageDetails = new PackageDetails(packageDetailsViewModel);

            var tmViewModel = new TranslationMemoriesViewModel(packageDetailsViewModel);

            _translationMemories = new TranslationMemories(tmViewModel);

            var finishViewModel = new FinishViewModel(tmViewModel, packageDetailsViewModel);

            _finish = new Finish(finishViewModel);

            var starTransitViewModel = new StarTransitMainWindowViewModel(
                packageDetailsViewModel,
                _packageDetails,
                _translationMemories,
                tmViewModel,
                finishViewModel,
                messageBoxService);

            DataContext = starTransitViewModel;

            if (starTransitViewModel.CloseAction == null)
            {
                starTransitViewModel.CloseAction = Close;
            }
        }
Exemplo n.º 10
0
        public IActionResult Details(string id)
        {
            Package package = this.packagesService.GetPackage(id);

            PackageDetailsViewModel viewModel = new PackageDetailsViewModel
            {
                Description     = package.Description,
                Recipient       = package.Recipient.UserName,
                ShippingAddress = package.ShippingAddress,
                Weight          = package.Weight,
                Status          = package.Status.Name
            };

            if (package.Status.Name == "Pending")
            {
                viewModel.EstimatedDeliveryDate = "N/A";
            }
            else if (package.Status.Name == "Shipped")
            {
                viewModel.EstimatedDeliveryDate = package.EstimatedDeliveryDate?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                viewModel.EstimatedDeliveryDate = "Delivered";
            }

            return(this.View(viewModel));
        }
        public IActionResult Details(int id)
        {
            var package = this.context.Packages
                          .FirstOrDefault(x => x.Id == id)
            ;
            var recipient = this.context.Users
                            .FirstOrDefault(x => x.Id == package.RecipientId);

            var detailsModel = new PackageDetailsViewModel
            {
                Address     = package.ShippingAddress,
                Weight      = package.Weight,
                Recipient   = recipient.UserName,
                Status      = package.Status.ToString(),
                Description = package.Description,
            };

            if (package.Status == PackageStatus.Pending)
            {
                detailsModel.EstimatedDeliveryDate = "N/A";
            }
            else if (package.Status == PackageStatus.Shipped)
            {
                detailsModel.EstimatedDeliveryDate = package.EstimatedDeliveryDate.Value.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                detailsModel.EstimatedDeliveryDate = "Delivered";
            }

            return(this.View(detailsModel));
        }
Exemplo n.º 12
0
        public IActionResult Details(string id)
        {
            Package package = this.context.Packages
                              .Where(packageFromDb => packageFromDb.Id == id)
                              .Include(packageFromDb => packageFromDb.Recipient)
                              .Include(packageFromDb => packageFromDb.Status)
                              .SingleOrDefault();

            PackageDetailsViewModel viewModel = new PackageDetailsViewModel()
            {
                Description     = package.Description,
                Recipient       = package.Recipient.UserName,
                ShippingAddress = package.ShippingAddress,
                Status          = package.Status.Name,
                Weight          = package.Weight
            };

            if (package.Status.Name == "Pending")
            {
                viewModel.EstimatedDeliveryDate = "N/A";
            }
            else if (package.Status.Name == "Shipped")
            {
                viewModel.EstimatedDeliveryDate = package.EstimatedDeliveryDate?
                                                  .ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                viewModel.EstimatedDeliveryDate = "Delivered";
            }

            return(this.View(viewModel));
        }
Exemplo n.º 13
0
        public async Task <IActionResult> Details(string Id)
        {
            var package = await this._packagesService
                          .GetPackageAsync(Id);

            if (package == null)
            {
                _logger.LogWarning($"Package with id {Id} - NOT FOUND!");
                return(this.NotFound());
            }

            var model = new PackageDetailsViewModel
            {
                Id = package.Id,
                //
                //!!!To Optimzie!!!
                ShippingAddress = this._addressesService
                                  .ShortenedAddressToString(
                    await this._addressesService.GetAddressByIdAsync(package.ShippingAddress)),

                /////////////////////////////////////////////////////////////////////////////////////
                Status = package.Status.ToString(),
                EstimatedDeliveryDate = package.EstimatedDeliveryDate?
                                        .ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
                Weight            = package.Weight,
                RecipientFullName = package.Recipient.FirstName + " " + package.Recipient.LastName.Substring(0, 1),
                Description       = package.Description
            };

            return(this.View(model));
        }
Exemplo n.º 14
0
        public IActionResult Details(string id)
        {
            var package = this.packagesService.GetPackageDetails(id);

            PackageDetailsViewModel model = this.mapper.Map <PackageDetailsViewModel>(package);

            return(this.View(model));
        }
Exemplo n.º 15
0
        public void TestViewPackageDetailsCommand()
        {
            // Arrange
            string      packageToOpen = "Sample View Extension";
            List <User> packageAuthor = new List <User> {
                new User {
                    _id = "1", username = "******"
                }
            };
            string packageDescription = "Dynamo sample view extension.";

            PackageDetailsViewExtension.PackageManagerClientViewModel = ViewModel.PackageManagerClientViewModel;

            PackageHeader packageHeader = new PackageHeader
            {
                _id      = null,
                name     = packageToOpen,
                versions = PackageVersions,
                latest_version_update = System.DateTime.Now,
                num_versions          = PackageVersions.Count,
                comments          = null,
                num_comments      = 0,
                latest_comment    = null,
                votes             = 0,
                downloads         = 0,
                repository_url    = null,
                site_url          = null,
                banned            = false,
                deprecated        = false,
                @group            = null,
                engine            = null,
                license           = null,
                used_by           = null,
                host_dependencies = Hosts,
                num_dependents    = 0,
                description       = packageDescription,
                maintainers       = packageAuthor,
                keywords          = null
            };
            PackageManagerSearchElement packageManagerSearchElement = new PackageManagerSearchElement(packageHeader);

            PackageDetailsViewExtension.OpenPackageDetails(packageManagerSearchElement);
            PackageDetailsView packageDetailsView = PackageDetailsViewExtension.PackageDetailsView;

            Assert.IsInstanceOf <PackageDetailsViewModel>(packageDetailsView.DataContext);
            PackageDetailsViewModel packageDetailsViewModel = packageDetailsView.DataContext as PackageDetailsViewModel;

            // Act
            PackageDetailsViewExtension.PackageManagerClientViewModel
            .DynamoViewModel
            .OnViewExtensionOpenWithParameterRequest("Package Details", packageManagerSearchElement);

            // Assert
            Assert.AreEqual(packageToOpen, packageDetailsViewModel.PackageName);
            Assert.AreEqual(packageAuthor.First().username, packageDetailsViewModel.PackageAuthorName);
            Assert.AreEqual(packageDescription, packageDetailsViewModel.PackageDescription);
        }
Exemplo n.º 16
0
        public void TestOpenDependencyDetails()
        {
            // Arrange
            string packageToOpen      = "Sample View Extension";
            string packageAuthor      = "DynamoTeam";
            string packageDescription = "Dynamo sample view extension.";

            PackageDetailsViewExtension.PackageManagerClientViewModel = ViewModel.PackageManagerClientViewModel;

            PackageHeader packageHeader = new PackageHeader
            {
                _id      = null,
                name     = string.Empty,
                versions = PackageVersions,
                latest_version_update = System.DateTime.Now,
                num_versions          = PackageVersions.Count,
                comments          = null,
                num_comments      = 0,
                latest_comment    = null,
                votes             = 0,
                downloads         = 0,
                repository_url    = null,
                site_url          = null,
                banned            = false,
                deprecated        = false,
                @group            = null,
                engine            = null,
                license           = null,
                used_by           = null,
                host_dependencies = Hosts,
                num_dependents    = 0,
                description       = null,
                maintainers       = UsersList,
                keywords          = null
            };
            PackageManagerSearchElement packageManagerSearchElement = new PackageManagerSearchElement(packageHeader);

            PackageDetailsViewExtension.OpenPackageDetails(packageManagerSearchElement);
            PackageDetailsView packageDetailsView = PackageDetailsViewExtension.PackageDetailsView;

            Assert.IsInstanceOf <PackageDetailsViewModel>(packageDetailsView.DataContext);
            PackageDetailsViewModel packageDetailsViewModel = packageDetailsView.DataContext as PackageDetailsViewModel;

            // Act
            packageDetailsViewModel.OpenDependencyDetails(packageToOpen);

            // Assert
            PackageDetailsView      newPackageDetailsView      = PackageDetailsViewExtension.PackageDetailsView;
            PackageDetailsViewModel newPackageDetailsViewModel = newPackageDetailsView.DataContext as PackageDetailsViewModel;

            Assert.AreEqual(packageToOpen, newPackageDetailsViewModel.PackageName);
            Assert.AreEqual(packageAuthor, newPackageDetailsViewModel.PackageAuthorName);
            Assert.AreEqual(packageDescription, newPackageDetailsViewModel.PackageDescription);
        }
Exemplo n.º 17
0
        public IHttpResponse Details(int id)
        {
            var user = this.Db.Users.FirstOrDefault(u => u.Username == this.User.Username);

            if (user == null)
            {
                return(this.Redirect("/users/login"));
            }

            var package = this.Db.Packages
                          .Include(p => p.Recipient)
                          .FirstOrDefault(p => p.Id == id);

            if (package == null)
            {
                return(this.BadRequestError("Invalid package id."));
            }

            if (this.User.Role == "User")
            {
                if (package.RecipientId != user.Id)
                {
                    return(this.BadRequestError("You don't have permission to view this package."));
                }
            }

            var viewModel = new PackageDetailsViewModel
            {
                Id            = id,
                Address       = package.ShippingAddress,
                Status        = package.Status,
                Weight        = package.Weight,
                RecipientName = package.Recipient.Username,
                Description   = package.Description
            };

            switch (package.Status)
            {
            case PackageStatus.Pending:
                viewModel.EstimatedDeliveryDate = "N/A";
                break;

            case PackageStatus.Shipped:
                viewModel.EstimatedDeliveryDate = package.EstimatedDeliveryDate.ToString(@"dd/MM/yyyy");
                break;

            default:
                viewModel.EstimatedDeliveryDate = "Delivered";
                break;
            }

            return(this.View("Packages/Details", viewModel));
        }
        public StarTransitMainWindow(PackageModel package)
        {
            EnsureApplicationResources();
            InitializeComponent();

            _packageDetails = new PackageDetails(package);
            var packageModel = PackageDetailsViewModel.GetPackageModel();

            _translationMemories = new TranslationMemories();
            _finish = new Finish(packageModel);

            DataContext = new StarTransitMainWindowViewModel(_packageDetails, _translationMemories, _finish);
            // DataContext = new StarTransitMainWindowViewModel(packageModel);
        }
Exemplo n.º 19
0
        public IHttpResponse Details(int id)
        {
            var package = Db.Packages.FirstOrDefault(x => x.Id == id);

            if (package == null)
            {
                return(BadRequestError("Package doesn`t exist"));
            }

            var viewModel = new PackageDetailsViewModel();

            FillViewModel(package, viewModel);

            return(this.View(viewModel));
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Details(PackageDetailsViewModel vm)
        {
            IdentityUser user = await _userManagerService.FindByNameAsync(User.Identity.Name);

            Package  package  = _packageService.GetSingle(p => p.Name == vm.Name);
            Feedback feedback = new Feedback
            {
                UserId    = user.Id,
                PackageId = package.PackageId,
                ComntDate = DateTime.Now,
                Comment   = vm.NewFeedback,
                UserName  = User.Identity.Name
            };

            _feedbackService.Create(feedback);
            return(RedirectToAction("Details", "Package", new { name = vm.Name }));
        }
Exemplo n.º 21
0
        public IHttpResponse Details(int id)
        {
            var package = this.Db.Packages.FirstOrDefault(p => p.Id == id);

            var estimatedDeliveryDate = GetDeliveryDate(package);

            var view = new PackageDetailsViewModel
            {
                Address = package.ShippingAddress,
                Status  = package.Status.ToString(),
                EstimatedDeliveryDate = estimatedDeliveryDate,
                Weight      = package.Weight,
                Recipient   = package.Recipient.Username,
                Description = package.Description
            };

            return(this.View(view));
        }
Exemplo n.º 22
0
        public IActionResult Details(Guid id)
        {
            var package = _packageService.GetPackageById(id);
            var user    = _userService.GetUserById(package.RecipientId);

            var packageDetailsViewModel = new PackageDetailsViewModel
            {
                Id                    = package.Id,
                Description           = package.Description,
                Weight                = package.Weight,
                ShippingAddreess      = package.ShippingAddreess,
                Status                = package.Status,
                EstimatedDeliveryDate = package.EstimatedDeliveryDate,
                RecipientName         = user.UserName
            };

            return(View(packageDetailsViewModel));
        }
Exemplo n.º 23
0
        public IActionResult Details()
        {
            var packageId        = int.Parse(this.Request.QueryData["id"].ToString());
            var package          = this.packagesService.GetPackageById(this.Identity, packageId);
            var packageViewModel = new PackageDetailsViewModel
            {
                Address = package.ShippingAddress,
                Status  = package.PackageStatus.ToString(),
                EstimatedDeliveryDate = package.EstimatedDeliveryDate != null?package.EstimatedDeliveryDate.Value.ToString("dd/MM/yyyy") : "N/A",
                                            Weight      = package.Weight,
                                            Recipient   = package.Recipient.Username,
                                            Description = package.Description
            };

            this.Model.Data["Package"] = packageViewModel;

            return(this.View());
        }
        public ResponseModel CreatePackageDetails(PackageDetailsViewModel packageData, List <ProductPackageVM> productList)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    DateTime aDate = DateTime.Now;

                    InvPackageMaster aPackageMaster = new InvPackageMaster()
                    {
                        PackageMasterId = packageData.PackageMasterId,
                        PackageName     = packageData.PackageName,
                        CreatedDate     = aDate,
                        IsActive        = true,
                        IsDeleted       = false,
                    };
                    _db.InvPackageMasters.Add(aPackageMaster);
                    _db.SaveChanges();

                    foreach (var aData in productList)
                    {
                        InvPackageDetail aPackageDetails = new InvPackageDetail()
                        {
                            PackageMasterId = aPackageMaster.PackageMasterId,
                            ProductId       = aData.ProductId,
                            ProductQuantity = aData.ProductQuantity,
                            IsActive        = true,
                            IsDeleted       = false,
                            CreatedDate     = aDate,
                        };
                        _db.InvPackageDetails.Add(aPackageDetails);
                    }
                    _db.SaveChanges();
                    transaction.Commit();
                    return(_aModel.Respons(true, "New Package Successfully Saved"));
                }
                catch (Exception)
                {
                    _db.SaveChanges();
                    transaction.Commit();
                    return(_aModel.Respons(true, "Failed to  Save New Package"));
                }
            }
        }
Exemplo n.º 25
0
        public async Task <IActionResult> Details(string name)
        {
            Package         pac  = _packageService.GetSingle(p => p.Name == name);
            List <Feedback> list = _feedbackService.Query(f => f.PackageId == pac.PackageId).OrderBy(f => f.ComntDate).ToList();
            IdentityUser    user = await _userManagerService.FindByIdAsync(pac.UserId);

            PackageDetailsViewModel vm = new PackageDetailsViewModel
            {
                Name         = pac.Name,
                LocationName = _locationService.GetSingle(l => l.LocationId == pac.LocationId).Name,
                Price        = pac.Price,
                Description  = pac.Description,
                Picture      = pac.Picture,
                UserName     = user.UserName,
                Feedbacks    = list
            };

            return(View(vm));
        }
Exemplo n.º 26
0
        public PackageDetailsViewModel Get(string id, string username, bool isAdmin)
        {
            var package = this.context.Packages
                          .Include(p => p.Recipient)
                          .FirstOrDefault(p => p.Id == id);

            if (package == null || !isAdmin &&
                (package.Recipient.Username != username || package.Status == Status.Acquired))
            {
                return(null);
            }

            string date = null;

            switch (package.Status)
            {
            case Status.Pending:
                date = "N/A";
                break;

            case Status.Shipped:
                date = package.EstimatedDeliveryDate?.ToString("dd/MM/yyyy");
                break;

            case Status.Delivered:
            case Status.Acquired:
                date = "Delivered";
                break;
            }

            var viewModel = new PackageDetailsViewModel
            {
                Address               = package.ShippingAddress,
                Description           = package.Description,
                EstimatedDeliveryDate = date,
                Weight    = package.Weight.ToString(),
                Recipient = package.Recipient.Username,
                Status    = package.Status.ToString()
            };

            return(viewModel);
        }
Exemplo n.º 27
0
        public void TestVersionsDisplayedInView()
        {
            // Arrange
            PackageHeader packageHeader = new PackageHeader {
                _id      = null,
                name     = string.Empty,
                versions = PackageVersions,
                latest_version_update = System.DateTime.Now,
                num_versions          = PackageVersions.Count,
                comments          = null,
                num_comments      = 0,
                latest_comment    = null,
                votes             = 0,
                downloads         = 0,
                repository_url    = null,
                site_url          = null,
                banned            = false,
                deprecated        = false,
                @group            = null,
                engine            = null,
                license           = null,
                used_by           = null,
                host_dependencies = Hosts,
                num_dependents    = 0,
                description       = null,
                maintainers       = UsersList,
                keywords          = null
            };
            PackageManagerSearchElement packageManagerSearchElement = new PackageManagerSearchElement(packageHeader);

            // Act
            PackageDetailsViewExtension.OpenPackageDetails(packageManagerSearchElement);
            PackageDetailsView packageDetailsView = PackageDetailsViewExtension.PackageDetailsView;

            // Assert
            Assert.IsNotNull(packageDetailsView.VersionsDataGrid);
            Assert.IsInstanceOf <PackageDetailsViewModel>(packageDetailsView.DataContext);

            PackageDetailsViewModel packageDetailsViewModel = packageDetailsView.DataContext as PackageDetailsViewModel;

            Assert.AreEqual(PackageVersions.Count, packageDetailsViewModel.PackageDetailItems.Count);
        }
Exemplo n.º 28
0
        public IHttpResponse Details(int id)
        {
            var package = this.DbContext.Packages.Find(id);

            if (package == null)
            {
                return(this.BadRequestErrorWithView($"Package with id {id} not found"));
            }

            if (this.User.Role != "Admin" && package.Recipient.Username != this.User.Username)
            {
                return(this.BadRequestError("You are not the owner of that package."));
            }

            var deliveryDate = string.Empty;

            if (package.Status == Status.Pending || package.EstimatedDeliveryDate.Value == null)
            {
                deliveryDate = "N/A";
            }
            else if (package.Status == Status.Shipped)
            {
                deliveryDate = package.EstimatedDeliveryDate.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            else
            {
                deliveryDate = "Delivered";
            }

            var model = new PackageDetailsViewModel
            {
                ShippingAddress       = package.ShippingAddress,
                Status                = package.Status.ToString(),
                Weight                = package.Weight,
                EstimatedDeliveryDate = deliveryDate,
                Description           = package.Description,
                Recipient             = package.Recipient.Username,
            };

            return(this.View(model));
        }
Exemplo n.º 29
0
        public IActionResult Details(int id)
        {
            TempData["packageId"] = id.ToString();

            Package package = _packageDataService.GetSingle(p => p.PackageId == id); //where available ADD IF AVAIL

            IEnumerable <Feedback> feedbackList = _feedbackDataService.Query(f => f.PackageId == id);

            PackageDetailsViewModel vm = new PackageDetailsViewModel
            {
                Name        = package.Name,
                Location    = package.Location,
                Price       = package.Price,
                Description = package.Description,
                Picture     = package.Picture,
                IsAvailable = package.IsAvailable,
                Feedbacks   = feedbackList
            };

            return(View(vm));
        }
Exemplo n.º 30
0
        public PackageDetailsViewModel GetPackageDetails(ApplicationUser user, int id)
        {
            var currentPackage = user.Packages
                                 .FirstOrDefault(p => p.Id == id);

            var details = new PackageDetailsViewModel()
            {
                Description           = currentPackage.Description,
                Status                = currentPackage.Status.ToString(),
                Address               = currentPackage.ShippingAddress,
                EstimatedDeliveryDate =
                    currentPackage.Status == Status.Pending? "N/A" :
                    currentPackage.Status == Status.Shipped?
                    currentPackage.EstimatedDeliveryDate?.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture) :
                    "Delivered",
                Recipient = currentPackage.Recipient.UserName,
                Weight    = currentPackage.Weight
            };

            return(details);
        }