public ActionResult Create(CarViewModel carView, HttpPostedFileBase uploadImage)
        {
            Logger.Debug("Attempt to create a new car.");
            try
            {
                if (uploadImage != null)
                {
                    //validate file format
                    string[] fileNameArr = uploadImage.FileName.Split('.');
                    if (!fileNameArr[fileNameArr.Length - 1].Equals("jpg") && !fileNameArr[fileNameArr.Length - 1].Equals("png") &&
                        !fileNameArr[fileNameArr.Length - 1].Equals("jpeg"))
                    {
                        throw new ValidationException("Wrong file format", "Photo");
                    }

                    byte[] imageData;
                    // reads uploaded file to byte array
                    using (var binaryReader = new BinaryReader(uploadImage.InputStream))
                    {
                        imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
                    }
                    carView.Photo = imageData;
                }

                var config = new MapperConfiguration(cfg => cfg.CreateMap <CarViewModel, CarDTO>());
                var mapper = config.CreateMapper();
                _rentService.CreateCar(mapper.Map <CarDTO>(carView));

                Logger.Info("New car added by {0}. Car info (brand: {1}, model: {2}, class: {3}, price: {4})",
                            User.Identity.Name, carView.Brand, carView.ModelName, carView.Class, carView.PriceForDay);
            }
            catch (ValidationException ex)
            {
                Logger.Debug("Car creating failed. Validation error (Property: {0}, Message: {1})", ex.Property, ex.Message);
                ModelState.AddModelError(ex.Property, ex.Message);
                return(View(carView));
            }
            return(RedirectToAction("Index"));
        }