Пример #1
0
        public VehicleSearchCriteriaViewModel(int id, string make, string model, int year, decimal price, int mileage, string transmission, string style, string condition, int cylinderNumber, string exteriorColor, int dealershipIdNumber, string dealershipName)
        {
            Id                 = id;
            Make               = make;
            Model              = model;
            Year               = year;
            Price              = price;
            Mileage            = mileage;
            Transmission       = transmission;
            Style              = style;
            Condition          = condition;
            CylinderNumber     = cylinderNumber;
            ExteriorColor      = exteriorColor;
            DealershipIdNumber = dealershipIdNumber;
            DealershipName     = dealershipName;

            var db           = new AutoScoutDBContext();
            var vehicleImage = db.VehicleImages.FirstOrDefault(x => x.VehicleId == Id);

            if (vehicleImage != null)
            {
                var imageBytes = vehicleImage.ImageBytes;
                //convert image byte array to base64 string to be rendered properly in browser
                var imageBytesBase64String = Convert.ToBase64String(imageBytes);
                ImageBytes = imageBytesBase64String;
            }
            else
            {
                byte[] errorImageArray = System.IO.File.ReadAllBytes(@"C:\Users\EvanBauer\Music\Git\AutoScout_Production\AutoScout_Production\AutoScout\AutoScout\Content\images\no_image_available.jpg");
                string base64ImageRepresentationError = Convert.ToBase64String(errorImageArray);
                ImageBytes = base64ImageRepresentationError;
            }
        }
Пример #2
0
        public Vehicle()
        {
            var context      = new AutoScoutDBContext();
            var service      = new DealershipAccountService(context);
            var dealershipId = service.GetCurrentUserDealershipIdFromIdentity();

            DealershipId = dealershipId;
            DateCreated  = DateTime.Now.ToUniversalTime();

            Visible = true;
            Active  = true;
        }
Пример #3
0
        public VehicleSearchCriteriaViewModel()
        {
            var db         = new AutoScoutDBContext();
            var imageBytes = db.VehicleImages.FirstOrDefault(x => x.VehicleId == Id).ImageBytes;

            if (imageBytes != null)
            {
                //convert image byte array to base64 string to be rendered properly in browser
                var imageBytesBase64String = Convert.ToBase64String(imageBytes);
                ImageBytes = imageBytesBase64String;
            }
            else
            {
                byte[] errorImageArray = System.IO.File.ReadAllBytes(@"C:\Users\EvanBauer\Music\Git\AutoScout_Production\AutoScout_Production\AutoScout\AutoScout\Content\images\no_image_available.jpg");
                string base64ImageRepresentationError = Convert.ToBase64String(errorImageArray);
                ImageBytes = base64ImageRepresentationError;
            }
        }
Пример #4
0
        public Vehicle()
        {
            var context = new AutoScoutDBContext();

            /*var firstImageFromDb = context.VehicleImages.First(x => x.VehicleId == this.Id);
             * if (firstImageFromDb != null)
             * {
             *  this.DefaultImage = firstImageFromDb;
             * }
             * var imagesFromDb = context.VehicleImages.Where(x => x.VehicleId == this.Id);
             *
             * if (imagesFromDb.Count() > 1)
             * {
             *  foreach (var image in imagesFromDb)
             *  {
             *      this.Images.Add(image);
             *  }
             * }*/
            var service       = new DealershipAccountService(context);
            var currentUserId = service.GetCurrentUserDealershipIdFromIdentity();

            this.DealershipId = currentUserId;
            DateCreated       = DateTime.UtcNow;
        }