Exemple #1
0
        public IActionResult AddBrand(int id)
        {
            var model = new BrandViewModel();

            if (id != 0)
            {
                try
                {
                    var brand = _brandApiCall.GetT(id);
                    model.Id   = brand.Id;
                    model.Name = brand.Name;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(View(model));
        }
Exemple #2
0
        public IActionResult AddModel(CarModelViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                if (model.Id == 0)
                {
                    var carModel = new Model
                    {
                        BrandId = model.BrandId,
                        Name    = model.Name
                    };
                    _modelApiCall.PostApiCall(carModel);


                    TempData["SuccessResultF"] = true;
                    TempData["SuccessResultM"] = "Model added successfully";
                }
                else
                {
                    var carModel = _modelApiCall.GetT(model.Id);
                    carModel.BrandId = model.BrandId;
                    carModel.Name    = model.Name;
                    _modelApiCall.PutApiCall(carModel, model.Id);


                    TempData["SuccessResultF"] = true;
                    TempData["SuccessResultM"] = "Model edited successfully";
                }
            }
            catch (Exception)
            {
                TempData["SuccessResultF"] = false;
                TempData["SuccessResultM"] = "Something went wrong.";
                throw;
            }
            return(RedirectToAction("Models", new { brandId = model.BrandId }));
        }
Exemple #3
0
        public IActionResult Index()
        {
            var model = new List <BookingViewModel>();

            var bookings = _bookingApiCalls.GetCallToApi();

            for (int i = 0; i < bookings.Count(); i++)
            {
                var pickUpLocation = _locationApiCall.GetT((int)bookings[i].PreBooking.PickLocationId);
                var returnLocation = _locationApiCall.GetT((int)bookings[i].PreBooking.ReturnLocationId);
                var pLoc           = pickUpLocation.StreetAddress + ", " + pickUpLocation.City + ", " + pickUpLocation.Country;
                var rLoc           = returnLocation.StreetAddress + ", " + returnLocation.City + ", " + returnLocation.Country;

                model.Add(new BookingViewModel
                {
                    Id             = bookings[i].Id,
                    CountBookings  = i + 1,
                    PickUpLocation = pLoc,
                    ReturnLocation = rLoc,
                    PickUpDate     = (DateTime)bookings[i].PreBooking.PickDate,
                    ReturnDate     = (DateTime)bookings[i].PreBooking.ReturnDate,

                    Car = new CarViewModel
                    {
                        Id        = bookings[i].Car.Id,
                        CarNumber = bookings[i].Car.CarNumber,
                    },
                    User = new AspNetUsersViewModel
                    {
                        Id          = bookings[i].User.Id,
                        FirstName   = bookings[i].User.FirstName,
                        LastName    = bookings[i].User.LastName,
                        Email       = bookings[i].User.Email,
                        PhoneNumber = bookings[i].User.PhoneNumber,
                    }
                });
            }

            return(View(model));
        }
Exemple #4
0
        public ActionResult AddLocation(int id)
        {
            var model = new LocationViewModel();

            if (id != 0)
            {
                try
                {
                    var location = _locationApiCall.GetT(id);

                    model.Id            = location.Id;
                    model.StreetAddress = location.StreetAddress;
                    model.City          = location.City;
                    model.ZipCode       = location.ZipCode;
                    model.Country       = location.Country;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(View(model));
        }
Exemple #5
0
        public IActionResult AddCar(int id)
        {
            var model = new CarViewModel();

            if (id != 0)
            {
                var car = _carApiGetCall.GetT(id);
                //var upload = _carRepository.GetCarUploadByCarId(id);

                string carLocation = car.CarLocation.StreetAddress + ", " + car.CarLocation.ZipCode + ", " + car.CarLocation.City + ", " + car.CarLocation.Country;

                model.Id                = car.Id;
                model.BrandName         = car.Brand.Name;
                model.CarCapacity       = car.CarCapacity;
                model.CarLocation       = carLocation;
                model.CarNumber         = car.CarNumber;
                model.Description       = car.Description;
                model.FuelType          = car.FuelType.Name;
                model.TransmisionType   = car.TransmisionType.Name;
                model.ModelName         = car.Model.Name;
                model.ModelYear         = car.ModelYear;
                model.NumberOfDoors     = car.NumberOfDoors;
                model.PriceForDay       = car.PriceForDay;
                model.BrandId           = car.Brand.Id;
                model.ModelId           = car.Model.Id;
                model.FuelTypeId        = car.FuelType.Id;
                model.TransmisionTypeId = car.TransmisionType.Id;
                model.LocationId        = car.CarLocation.Id;
                model.CarColor          = car.CarColor;
                //model.Path = upload.Path;
            }


            SelectLists(model);
            return(View(model));
        }
Exemple #6
0
        public IActionResult Details(int id)
        {
            var model  = new BookingViewModel();
            var car    = new CarViewModel();
            var userVm = new AspNetUsersViewModel();

            var booking = _bookingApiCalls.GetT(id);

            var pickUpLocation = _locationApiCall.GetT((int)booking.PreBooking.PickLocationId);
            var returnLocation = _locationApiCall.GetT((int)booking.PreBooking.ReturnLocationId);
            var pLoc           = pickUpLocation.StreetAddress + ", " + pickUpLocation.City + ", " + pickUpLocation.Country;
            var rLoc           = returnLocation.StreetAddress + ", " + returnLocation.City + ", " + returnLocation.Country;

            car.Id        = booking.Car.Id;
            car.CarNumber = booking.Car.CarNumber;
            car.BrandName = booking.Car.Brand.Name;
            car.ModelName = booking.Car.Model.Name;
            //car.Path = Url.Content(_carRepository.GetUploadByCarId(booking.Car.Id));
            car.NumberOfDoors = booking.Car.NumberOfDoors;
            car.CarCapacity   = booking.Car.CarCapacity;


            userVm.Id          = booking.User.Id;
            userVm.FirstName   = booking.User.FirstName;
            userVm.LastName    = booking.User.LastName;
            userVm.Email       = booking.User.Email;
            userVm.PhoneNumber = booking.User.PhoneNumber;

            model.Id             = booking.Id;
            model.PickUpLocation = pLoc;
            model.ReturnLocation = rLoc;
            model.PickUpDate     = (DateTime)booking.PreBooking.PickDate;
            model.ReturnDate     = (DateTime)booking.PreBooking.ReturnDate;
            model.Car            = car;
            model.User           = userVm;
            //model.CanBeDeleted = (DateTime)booking.PreBooking.ReturnDate < DateTime.Now ? true : false;

            return(View(model));
        }