コード例 #1
0
        // GET: Dealerships/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                Dealership dealership = await db.Dealerships.FindAsync(id);

                if (dealership == null)
                {
                    return(HttpNotFound());
                }
                //use the image management service to get the background image converted to a base 64 string
                var imageService = new ImageManagementService(db);

                var iconString       = "";
                var backgroundString = "";

                if (dealership.Icon != null)
                {
                    var dealershipIconImage = imageService.GetDealershipProfileIconAsBase64String(dealership.Id);
                    iconString = "data:image/png;base64," + dealershipIconImage;
                }

                if (dealership.ProfileBackgroundImage != null)
                {
                    var dealershipBackgroundImage = imageService.GetDealershipProfileBackgroundAsBase64String(dealership.Id);
                    backgroundString = "data:image/png;base64," + dealershipBackgroundImage;
                }

                //pass image base 64 strings to view using ViewBag
                ViewBag.Icon       = iconString;
                ViewBag.Background = backgroundString;

                //acquire full vehicle inventory
                var dealershipService = new DealershipAccountService(db);
                var vehicles          = dealershipService.GetAllVehiclesInInventory(dealership.Id);

                ViewBag.Vehicles = vehicles.ToList();

                return(View(dealership));
            }
            catch (Exception ex)
            {
                var errorService = new ErrorService(db);
                errorService.logError(ex);

                throw (ex);
            }
        }
コード例 #2
0
        public string GetProfileIconImage(int id)
        {
            try
            {
                //use the image management service to get the background image converted to a base 64 string
                var imageService        = new ImageManagementService(db);
                var dealershipIconImage = imageService.GetDealershipProfileIconAsBase64String(id);

                //create a new object easily converted to json to be acquired in the view
                //var icon = new ImageRenderViewModel(dealershipIconImage);

                return(dealershipIconImage);
            }
            catch (Exception ex)
            {
                var errorService = new ErrorService(db);
                errorService.logError(ex);

                throw (ex);
            }
        }