Exemple #1
0
        public IActionResult Index()
        {
            var model = new List <BrandViewModel>();
            var brand = _brandApiCall.GetCallToApi();

            foreach (var item in brand)
            {
                bool canBeDeleted = false;
                if (item.Car.Count == 0)
                {
                    canBeDeleted = true;
                }
                model.Add(new BrandViewModel
                {
                    Id           = item.Id,
                    Name         = item.Name,
                    CanBeDeleted = canBeDeleted
                });
            }

            try
            {
                ViewData["flag"]    = (bool)TempData["SuccessResultF"];
                ViewData["message"] = TempData["SuccessResultM"].ToString();
            }
            catch (Exception) { }
            return(View(model));
        }
Exemple #2
0
        public IActionResult Index()
        {
            var model     = new List <LocationViewModel>();
            var locations = _locationApiCall.GetCallToApi();

            foreach (var item in locations)
            {
                bool locationUsed = false;
                if (item.Car.Count == 0)
                {
                    locationUsed = true;
                }

                model.Add(new LocationViewModel
                {
                    Id            = item.Id,
                    StreetAddress = item.StreetAddress,
                    City          = item.City,
                    Country       = item.Country,
                    ZipCode       = item.ZipCode,
                    CenBeDeleted  = locationUsed
                });
            }

            try
            {
                ViewData["flag"]    = (bool)TempData["SuccessResultF"];
                ViewData["message"] = TempData["SuccessResultM"].ToString();
            }
            catch (Exception) { }

            return(View(model));
        }
Exemple #3
0
        // GET: Fuel
        public IActionResult Index()
        {
            var viewModel = new List <FuelViewModel>();


            var model = _apiGetCalls.GetCallToApi();

            for (int i = 0; i < model.Count(); i++)
            {
                var canBedeleted = false;

                if (model[i].Car.Count == 0)
                {
                    canBedeleted = true;
                }
                viewModel.Add(new FuelViewModel
                {
                    Id           = model[i].Id,
                    Name         = model[i].Name,
                    CanBeDeleted = canBedeleted
                });
            }


            return(View(viewModel));
        }
Exemple #4
0
        // GET: AspNetUsers
        public ActionResult Index()
        {
            var model = new List <AspNetUsersViewModel>();
            var users = _apiCalls.GetCallToApi();

            foreach (var item in users)
            {
                try
                {
                    var canBeDeleted = true;

                    if (item.Booking.Count() != 0)
                    {
                        canBeDeleted = false;
                    }

                    model.Add(new AspNetUsersViewModel
                    {
                        Id           = item.Id,
                        FirstName    = item.FirstName,
                        LastName     = item.LastName,
                        PhoneNumber  = item.PhoneNumber,
                        UserName     = item.Email,
                        CanBeDeleted = canBeDeleted
                    });
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(View(model));
        }
Exemple #5
0
        public IEnumerable <KeyValue> GetLocations()
        {
            var locations = _locationApiCalls.GetCallToApi();

            var values = locations.Select(x => new KeyValue
            {
                Key   = x.Id,
                Value = x.StreetAddress + ", " + x.ZipCode + ", " + x.City + ", " + x.Country
            });

            return(values);
        }
Exemple #6
0
        public IEnumerable <KeyValue> GetTransmisionTypes()
        {
            var transmisionTypes = _transmissionApiCalls.GetCallToApi();

            var values = transmisionTypes.Select(x => new KeyValue
            {
                Key   = x.Id,
                Value = x.Name
            });

            return(values);
        }
Exemple #7
0
        public IEnumerable <KeyValue> GetFuelTypes()
        {
            var fuelTypes = _fuelApiCalls.GetCallToApi();

            var values = fuelTypes.Select(x => new KeyValue
            {
                Key   = x.Id,
                Value = x.Name
            });

            return(values);
        }
Exemple #8
0
        public IEnumerable <KeyValue> GetBrandsKeyValue()
        {
            var brands = _brandApiCalls.GetCallToApi();

            var values = brands.Select(x => new KeyValue
            {
                Key   = x.Id,
                Value = x.Name
            });

            return(values);
        }
Exemple #9
0
        // GET: Car
        public IActionResult Index()
        {
            var viewModel = new List <CarViewModel>();

            var model = _carApiGetCall.GetCallToApi();

            for (int i = 0; i < model.Count(); i++)
            {
                var canBedeleted = true;

                if (model[i].Booking.Count() != 0)
                {
                    canBedeleted = false;
                }
                viewModel.Add(new CarViewModel
                {
                    Id              = model[i].Id,
                    CarNumber       = model[i].CarNumber,
                    BrandName       = model[i].Brand.Name,
                    ModelName       = model[i].Model.Name,
                    CarCapacity     = model[i].CarCapacity,
                    CarLocation     = model[i].CarLocation.StreetAddress,
                    FuelType        = model[i].FuelType.Name,
                    ModelYear       = model[i].ModelYear,
                    NumberOfDoors   = model[i].NumberOfDoors,
                    TransmisionType = model[i].TransmisionType.Name,
                    PriceForDay     = model[i].PriceForDay,
                    Description     = model[i].Description,
                    Path            = Url.Content(model[i].CarUpload.Select(x => x.Path).FirstOrDefault()),
                    CanBeDeleted    = canBedeleted
                });
            }

            //else
            //{

            //    viewModel = Enumerable.Empty<CarViewModel>().ToList();

            //    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");

            //}


            return(View(viewModel));
        }
Exemple #10
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));
        }