예제 #1
0
        public async Task <bool> AddCarReservationAsync(CarReservation reservation)
        {
            var carReservation = await context.CarReservations.FirstOrDefaultAsync(item => item.Id == reservation.Id);

            if (carReservation is object)
            {
                return(false);
            }
            var car = await context.Cars.FirstOrDefaultAsync(item => item.Id == reservation.ReservedCarId);

            //var user = await context.User.FirstOrDefaultAsync(item => item.Email == reservation.OwnerEmail);
            car.IsReserved = true;
            if (reservation.Discount > 0)
            {
                var costPerDay = (reservation.To - reservation.From).Value.TotalDays * car.CostPerDay;
                reservation.CostForRange = costPerDay - (costPerDay * (reservation.Discount / 100));
            }
            reservation.ReservedCar = car;
            //reservation.Owner = user;
            await context.CarReservations.AddAsync(reservation);

            await context.SaveChangesAsync();

            return(true);
        }
예제 #2
0
        public ActionResult Reservation([Bind(Include = "Id,DtTrx,CarUnitId,DtStart,LocStart,DtEnd,LocEnd,BaseRate,Destinations,UseFor,RenterName,RenterCompany,RenterEmail,RenterMobile,RenterAddress,RenterFbAccnt,RenterLinkedInAccnt,EstHrPerDay,EstKmTravel,JobRefNo,SelfDrive")] CarReservation carReservation)
        {
            if (ModelState.IsValid)
            {
                db.CarReservations.Add(carReservation);
                db.SaveChanges();

                //self drive reservation
                addCarResPackage(carReservation.Id, 1, 0, 0);

                //sendMail(jobid ,RenterEmail);
                //sent email to the user
                var adminEmail = "*****@*****.**";
                sendMail(carReservation.Id, adminEmail, "ADMIN", carReservation.RenterName);

                adminEmail = "*****@*****.**";
                sendMail(carReservation.Id, adminEmail, "ADMIN", carReservation.RenterName);

                adminEmail = "*****@*****.**";
                sendMail(carReservation.Id, adminEmail, "ADMIN", carReservation.RenterName);

                //Client Email
                sendMail(carReservation.Id, carReservation.RenterEmail, "CLIENT-PENDING", carReservation.RenterName);

                return(RedirectToAction("FormThankYou", new { rsvId = carReservation.Id }));
                // return RedirectToAction("ReservationNotification");
            }

            return(View("Reservation", new { unitid = carReservation.CarUnitId }));
        }
예제 #3
0
        public async Task <IActionResult> MakeCarReservation(CarReservationRequestModel carReservationModel) //Koristimo samo da smjestimo id
        {
            using (var transaction = _dbContext.Database.BeginTransaction())
            {
                Car car = _dbContext.Cars.Include(x => x.CarReservations).Where(x => x.Id == carReservationModel.CarId).SingleOrDefault();
                if (car == null)
                {
                    return(Ok(new { message = "Car does not exist!" }));
                }

                CarReservation cr = new CarReservation();

                DateTime startDate = Convert.ToDateTime(carReservationModel.FirstDayOfReservation);
                DateTime endDate   = Convert.ToDateTime(carReservationModel.LastDayOfReservation);

                cr.FirstDayOfReservaton = startDate;
                cr.LastDayOfReservaton  = endDate;

                int dayDifference = (endDate.Date - startDate.Date).Days;
                cr.TotalPrice = dayDifference * Int32.Parse(carReservationModel.PricePerDay);
                cr.OwnerId    = carReservationModel.OwnerId;

                car.CarReservations.Add(cr);
                _dbContext.SaveChanges();
                transaction.Commit();

                return(Ok(new { message = "New reservation is successfully added!" }));
            }
        }
        public ActionResult ReservationRedirect(int id, string month, string day, string year, string rName)
        {
            String   DateBook = month + "/" + day + "/" + year;
            DateTime booking  = DateTime.Parse(DateBook);
            int      iMonth   = int.Parse(month);
            int      iday     = int.Parse(day);
            int      iyear    = int.Parse(year);

            CarReservation job = db.CarReservations.
                                 Where(j => j.Id == id).Where(j => j.DtTrx.Month == iMonth && j.DtTrx.Day == iday && j.DtTrx.Year == iyear).
                                 Where(j => j.RenterName == rName).
                                 FirstOrDefault();

            //fillout empty
            job.LocStart            = job.LocStart == null ? "N/A" : job.LocStart;
            job.LocEnd              = job.LocEnd == null ? "N/A" : job.LocEnd;
            job.RenterCompany       = job.RenterCompany == null ? "N/A" : job.RenterCompany;
            job.RenterAddress       = job.RenterAddress == null ? "N/A" : job.RenterAddress;
            job.RenterFbAccnt       = job.RenterFbAccnt == null ? "N/A" : job.RenterFbAccnt;
            job.RenterLinkedInAccnt = job.RenterLinkedInAccnt == null ? "N/A" : job.RenterLinkedInAccnt;

            ViewBag.rentalType = job.SelfDrive == 1 || job.SelfDrive == null ? "Self Drive" : "With Driver";

            return(View("Details", job));
        }
예제 #5
0
        public void FormRenter(string DtTrx, string CarUnitId, string DtStart, string LocStart,
                               string DtEnd, string LocEnd, string BaseRate, string Destinations, string UseFor,
                               string RenterName, string RenterCompany, string RenterEmail, string RenterMobile,
                               string RenterAddress, string RenterFbAccnt, string RenterLinkedInAccnt, string EstHrPerDay,
                               string EstKmTravel)
        {
            CarReservation carReservation = new CarReservation();

            carReservation.DtTrx               = DateTime.Parse(DtTrx);
            carReservation.CarUnitId           = int.Parse(CarUnitId);
            carReservation.DtStart             = DtStart;
            carReservation.LocStart            = LocStart;
            carReservation.DtEnd               = DtEnd;
            carReservation.LocEnd              = LocEnd;
            carReservation.BaseRate            = BaseRate;
            carReservation.Destinations        = Destinations;
            carReservation.UseFor              = UseFor;
            carReservation.RenterName          = RenterName;
            carReservation.RenterEmail         = RenterEmail;
            carReservation.RenterMobile        = RenterMobile;
            carReservation.RenterAddress       = RenterAddress;
            carReservation.RenterFbAccnt       = RenterFbAccnt;
            carReservation.RenterLinkedInAccnt = RenterLinkedInAccnt;
            carReservation.EstHrPerDay         = int.Parse(EstHrPerDay);
            carReservation.EstKmTravel         = int.Parse(EstKmTravel);

            db.CarReservations.Add(carReservation);
            db.SaveChanges();
        }
예제 #6
0
        public async Task <OperationResponse <CarReservation> > MakeReservationAsync(CarReservation carReservation)
        {
            var carFromReservation = await _carRepository.GetAsync(carReservation.CarId);

            if (carFromReservation == null)
            {
                return(new OperationResponse <CarReservation>()
                       .SetAsFailureResponse(OperationErrorDictionary.CarReservation.CarDoesNotExist()));
            }

            var existingCarReservation = await _carReservationRepository.GetExistingReservationByCarIdAsync(carReservation.CarId, carReservation.RentFrom);

            if (existingCarReservation != null)
            {
                return(new OperationResponse <CarReservation>()
                       .SetAsFailureResponse(OperationErrorDictionary.CarReservation.CarAlreadyReserved()));
            }

            else
            {
                carReservation.Id         = Guid.NewGuid().ToString();
                carReservation.CustomerId = _identityService.GetUserIdentity().ToString();
                var createdCarReservation = await _carReservationRepository.AddAsync(carReservation);

                return(new OperationResponse <CarReservation>(createdCarReservation));
            }
        }
예제 #7
0
        public CarReservation InsertCarReservation(int id_vehiculo, int id_cliente, string nombre, string apellido, string telefono, string correo, string horaentrada, string horasalida, string fechaentrada, string fechasalida, string lugar)
        {
            CarReservation reservation = new CarReservation();

            using (CarDBEntities dc = new CarDBEntities())
            {
                reservation.idVehiculo   = id_vehiculo;
                reservation.idCliente    = id_cliente;
                reservation.nombre       = nombre;
                reservation.apellidos    = apellido;
                reservation.telefono     = telefono;
                reservation.correo       = correo;
                reservation.horaentrada  = horaentrada;
                reservation.horasalida   = horasalida;
                reservation.fechaentrada = fechaentrada;
                reservation.fechasalida  = fechasalida;
                reservation.lugar        = lugar;

                dc.Configuration.ValidateOnSaveEnabled = false;
                dc.CarReservations.Add(reservation);
                dc.SaveChanges();
            }

            return(null);
        }
예제 #8
0
        public ActionResult FormRenter([Bind(Include = "Id,DtTrx,CarUnitId,DtStart,LocStart,DtEnd,LocEnd,BaseRate,Destinations,UseFor,RenterName,RenterCompany,RenterEmail,RenterMobile,RenterAddress,RenterFbAccnt,RenterLinkedInAccnt,EstHrPerDay,EstKmTravel,JobRefNo,SelfDrive")] CarReservation carReservation, int packageid, int mealAcc, int fuel, string host)
        {
            if (ModelState.IsValid)
            {
                db.CarReservations.Add(carReservation);
                db.SaveChanges();

                //add reservation package
                addCarResPackage(carReservation.Id, packageid, mealAcc, fuel);

                //sent email to [email protected]
                var adminEmail = "*****@*****.**";
                sendMail(carReservation.Id, adminEmail, "ADMIN", carReservation.RenterName);

                adminEmail = "*****@*****.**";
                sendMail(carReservation.Id, adminEmail, "ADMIN", carReservation.RenterName);

                //client email
                sendMail(carReservation.Id, carReservation.RenterEmail, "CLIENT-PENDING", carReservation.RenterName);

                return(RedirectToAction("FormThankYou", new { rsvId = carReservation.Id }));
            }

            ViewBag.CarUnitId        = new SelectList(db.CarUnits, "Id", "Description", carReservation.CarUnitId);
            ViewBag.id               = carReservation.CarUnitId;
            ViewBag.carRatesPackages = db.CarRateUnitPackages.ToList();
            ViewBag.CarUnitList      = db.CarUnits.ToList();
            ViewBag.CarRates         = db.CarRates.ToList();
            ViewBag.Packages         = db.CarRatePackages.ToList();

            return(View(carReservation));
        }
예제 #9
0
        public async Task <CarReservation> MakeReservation(CarReservationModel reservation)
        {
            Car car = await GetCar(reservation.CarId);

            car.IsReserved = true;

            var carReservation = new CarReservation()
            {
                Car       = car,
                EndDate   = reservation.EndDate,
                FullPrice = reservation.FullPrice,
                StartDate = reservation.StartDate,
                UserEmail = reservation.UserEmail
            };

            //update this car in db
            _context.Car.Update(car);

            //write in reservations
            _context.CarReservations.Add(carReservation);

            await _context.SaveChangesAsync();

            //posalji izvestaj na email
            await _emailSender.SendEmailAsync(carReservation.UserEmail,
                                              "Succesfull car reservation!",
                                              $"<h2>Congratulations!</h2><p>You made a successful car reservation. Your {carReservation.Car.Mark} is ready to go!</p>");

            return(carReservation);
        }
        public async Task <IActionResult> PostCarRate(long id, [FromBody] CarVehicleRatingDTO model)
        {
            if (ModelState.IsValid)
            {
                CarReservation vehicleReser = await _reservationService.GetCarReservationById(id);

                Vehicle vehicle = await _vehicleService.GetVehicleById(vehicleReser.VehicleId);

                RegularUser user = await _userService.GetCurrentUser();

                CarCompanyRating ccRate = new CarCompanyRating();
                ccRate.CarReservationId = id;
                ccRate.CarCompanyId     = vehicle.CarCompanyId;
                ccRate.UserId           = user.Id;
                ccRate.Rate             = model.ratingCarCompany;

                VehicleRating vehicleRate = new VehicleRating();
                vehicleRate.CarReservationId = id;
                vehicleRate.VehicleId        = vehicle.VehicleId;
                vehicleRate.Rate             = model.ratingVehicle;
                vehicleRate.UserId           = user.Id;

                await _userService.AddCarRating(ccRate);

                await _userService.AddVehicleRating(vehicleRate);

                return(Ok(200));
            }
            return(BadRequest());
        }
예제 #11
0
        // GET: CarReservations/Create
        public ActionResult FormRenter(int?id)
        {
            DateTime today = DateTime.Now;

            today = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(today, TimeZoneInfo.Local.Id, "Singapore Standard Time");

            CarReservation reservation = new CarReservation();

            reservation.DtTrx       = today;
            reservation.DtStart     = today.AddDays(2).ToString();
            reservation.DtEnd       = today.AddDays(3).ToString();
            reservation.JobRefNo    = 0;
            reservation.SelfDrive   = 0;  //with driver = 0, self drive = 1;
            reservation.EstHrPerDay = 10;
            reservation.EstKmTravel = 100;

            //get previous id
            CarReservation lastId = db.CarReservations.ToList().OrderByDescending(c => c.Id).LastOrDefault();

            CarRatePackage selfDrive = db.CarRatePackages.Find(1);

            //get last reservation id
            ViewBag.RsvId = lastId != null ?  lastId.Id + 1 : 1;

            ViewBag.CarUnitId        = new SelectList(db.CarUnits, "Id", "Description", id);
            ViewBag.id               = id;
            ViewBag.carRatesPackages = db.CarRateUnitPackages.ToList();
            ViewBag.CarUnitList      = db.CarUnits.ToList();
            ViewBag.CarRates         = db.CarRates.ToList();
            ViewBag.isAuthorize      = HttpContext.User.Identity.Name == ""  ? 0 : 1;

            //except self drive package
            ViewBag.Packages = db.CarRatePackages.ToList();
            return(View(reservation));
        }
        // GET: CarReservations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarReservation cr = db.CarReservations.Find(id);

            if (cr == null)
            {
                return(HttpNotFound());
            }


            //fillout empty
            cr.LocStart            = cr.LocStart == null ? "N/A" : cr.LocStart;
            cr.LocEnd              = cr.LocEnd == null ? "N/A" : cr.LocEnd;
            cr.RenterCompany       = cr.RenterCompany == null ? "N/A" : cr.RenterCompany;
            cr.RenterAddress       = cr.RenterAddress == null ? "N/A" : cr.RenterAddress;
            cr.RenterFbAccnt       = cr.RenterFbAccnt == null ? "N/A" : cr.RenterFbAccnt;
            cr.RenterLinkedInAccnt = cr.RenterLinkedInAccnt == null ? "N/A" : cr.RenterLinkedInAccnt;
            ViewBag.rentalType     = cr.SelfDrive == 1 ? "With Driver" : "Self Drive";

            return(View(cr));
        }
예제 #13
0
        public ActionResult Reservation(int unitid)
        {
            DateTime today = DateTime.Now;

            today = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(today, TimeZoneInfo.Local.Id, "Singapore Standard Time");

            //defaults
            CarReservation reservation = new CarReservation();

            reservation.DtTrx       = today;
            reservation.DtStart     = today.AddDays(2).ToString();
            reservation.DtEnd       = today.AddDays(3).ToString();
            reservation.EstHrPerDay = 0;
            reservation.EstKmTravel = 0;
            reservation.JobRefNo    = 0;
            reservation.SelfDrive   = 1;     //with driver = 0, self drive = 1;

            ViewBag.CarUnitId = new SelectList(db.CarUnits, "Id", "Description", unitid);

            var carrate = db.CarRates.Where(d => d.CarUnitId == unitid).FirstOrDefault();

            ViewBag.CarRate      = carrate.Daily;
            ViewBag.objCarRate   = carrate; // db.CarRates.Where(d => d.CarUnitId == unitid);
            ViewBag.Destinations = db.CarDestinations.Where(d => d.CityId == 1).OrderBy(d => d.Kms).ToList();
            ViewBag.UnitId       = unitid;

            return(View(reservation));
        }
예제 #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            CarReservation carReservation = _carReservationRepository.GetWhere(i => i.Id == id).FirstOrDefault();

            _carReservationRepository.Delete(carReservation);
            return(RedirectToAction("Index"));
        }
예제 #15
0
        public async Task <IActionResult> CarReservation([FromBody] CarReservationDTO model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserService.GetCurrentUser();

                if (user != null)
                {
                    var pickUpTime  = DateTime.ParseExact(model.ReservationDetails.PickUpTime, "H:mm", null, System.Globalization.DateTimeStyles.None);
                    var returnTime  = DateTime.ParseExact(model.ReservationDetails.ReturnTime, "H:mm", null, System.Globalization.DateTimeStyles.None);
                    var reservation = new CarReservation()
                    {
                        PickUpDate     = model.ReservationDetails.PickUpDate.Add(pickUpTime.TimeOfDay),
                        PickUpLocation = new Destination()
                        {
                            Name = model.ReservationDetails.PickUpLocation
                        },
                        ReturnDate     = model.ReservationDetails.ReturnDate.Add(returnTime.TimeOfDay),
                        ReturnLocation = new Destination()
                        {
                            Name = model.ReservationDetails.ReturnLocation,
                        },
                        VehicleId = model.VehicleId,
                        Finished  = true
                    };

                    user.ReservedCars.Add(reservation);
                    await UserService.UpdateUser(user);

                    return(Ok(200));
                }
            }

            return(BadRequest(ModelState));
        }
예제 #16
0
        public async Task <Object> CarReservation(MakeReservationcs reservation)
        {
            var    car    = _context.Cars.Include(x => x.CarReservations).Where(x => x.Id == reservation.CarId).ToList().First();
            bool   test   = false;
            string userID = User.Claims.ElementAt(0).Value;
            var    user   = _context.Users.Include(x => x.CarReservations).Where(x => x.Id == userID).ToList().First();

            foreach (var item in car.CarReservations)
            {
                if (reservation.PickupDate > item.PickupDate && reservation.PickupDate < item.ReturnDate)
                {
                    test = true;
                    break;
                }

                if (reservation.PickupDate > item.PickupDate && reservation.ReturnDate < item.ReturnDate)
                {
                    test = true;
                    break;
                }



                if (reservation.PickupDate < item.PickupDate && reservation.ReturnDate > item.PickupDate)
                {
                    test = true;
                    break;
                }

                if (reservation.PickupDate < item.PickupDate && reservation.ReturnDate > item.ReturnDate)
                {
                    test = true;
                    break;
                }
            }
            if (test)
            {
                return(BadRequest(new { message = "Already reserved in this period" }));
            }
            else
            {
                var carreservation = new CarReservation();
                carreservation.NumberOfDays = reservation.NumberOfDays;
                carreservation.PickupDate   = reservation.PickupDate;
                carreservation.ReturnDate   = reservation.ReturnDate;
                carreservation.TotalPrice   = reservation.NumberOfDays * car.PricePerDay;
                carreservation.Location     = car.Location;
                carreservation.Brand        = car.Brand;
                carreservation.Model        = car.Model;
                car.CarReservations.Add(carreservation);
                user.CarReservations.Add(carreservation);
                _context.Entry(car).State  = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                var result = await _context.SaveChangesAsync();

                return(Ok(new { result }));
            }
        }
 public static CarReservationDto MapToDto(CarReservation carReservation)
 {
     return(new CarReservationDto
     {
         CarId = carReservation.CarId,
         RentFrom = carReservation.RentFrom,
         RentTo = carReservation.RentTo
     });
 }
        public ActionResult DeleteConfirmed(int id)
        {
            CarReservation carReservation = db.CarReservations.Find(id);

            db.CarReservations.Remove(carReservation);
            DeleteCarResPackages(carReservation.Id);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #19
0
 public ActionResult Edit([Bind(Include = "Id,StartDate,EndDate,StartPlace,EndPlace")] CarReservation carReservation)
 {
     if (ModelState.IsValid)
     {
         _carReservationRepository.Edit(carReservation);
         return(RedirectToAction("Index"));
     }
     return(View(carReservation));
 }
예제 #20
0
        public ActionResult Create(CarReservation carReservation)
        {
            if (ModelState.IsValid)
            {
                _carReservationRepository.Create(carReservation);
                return(RedirectToAction("Index"));
            }

            return(View(carReservation));
        }
        public async Task <Object> CancelCarReservation(string id)
        {
            string userId = "";
            User   user   = new User();
            await Task.Run(() =>
            {
                userId = User.Claims.First(c => c.Type == "UserID").Value;
                user   = _dataBase.Users.Include(u => u.ReservedCars).ToList().Find(u => u.UserName == userId);
            });

            if (user == null || user.Role != "ru")
            {
                return(Unauthorized());
            }

            var resId = 0;
            var res   = new CarReservation();
            var date  = new DateTime();
            await Task.Run(() =>
            {
                resId = int.Parse(id);

                res  = _dataBase.CarReservations.Include(res => res.Vehicle).ToList().Find(c => c.Id == resId);
                date = res.StartDate;
                date.AddDays(2);
            });

            if (date <= DateTime.Now)
            {
                return(BadRequest("Deadline for canceling reservation has passed"));
            }

            var car = new Vehicle();
            await Task.Run(() =>
            {
                car = _dataBase.Vehicles.Include(v => v.DatesTaken).ToList().Find(v => v.Id == res.Vehicle.Id);

                for (var d = res.StartDate; d <= res.EndDate; d = d.AddDays(1))
                {
                    car.DatesTaken.ToList().RemoveAll(t => t.DateTime == d);
                }

                //_dataBase.CarReservations.Remove(res);
                user.ReservedCars.Remove(res);
                var rent   = _dataBase.Rentacars.Include(r => r.ProfitList).ToList().Find(r => r.Id == res.Vehicle.RentacarID);
                var profit = _dataBase.Profits.ToList().Find(p => p.RentacarID == rent.Id && p.CarReservationID == res.Id);
                rent.ProfitList.Remove(profit);
                _dataBase.CarReservations.Remove(res);
                _dataBase.Profits.Remove(profit);
                _dataBase.SaveChanges();
                var ret = _dataBase.CarReservations.Include(c => c.Vehicle).ToList().FindAll(c => c.User == user.UserName);
            });

            return(Ok(user.ReservedCars));
        }
예제 #22
0
        public static void RemovedAndUpdateEBLForPoliceList(string bookingItemID)
        {
            try
            {
                // Get the carReservation from EBL table CarReservationData
                CarReservationData carReservationData     = CarBSDB.getCarReservationData(int.Parse(bookingItemID));
                CarReservation     expectedCarReservation = (CarReservation)FastInfoSetSerializer.DeserializeFIInDB((byte[])carReservationData.CarReservationNodeData, typeof(CarReservation));

                // removed police list
                if (expectedCarReservation.CarPolicyList.CarPolicy.Count == 0)
                {
                    Console.WriteLine("No car policy list exist in CarReservation , don't need remove it.");
                }
                else
                {
                    expectedCarReservation.CarPolicyList = null;
                }

                Console.WriteLine("Begin update the DB for CarReservationData ...");
                SqlConnection     conn       = new SqlConnection(connectionString);
                DataSet           dsSet      = new DataSet();
                SqlDataAdapter    sdaAdapter = null;
                SqlCommandBuilder scbBuilder = null;

                //SqlCommand cmdUpdate = null;
                SqlCommand cmd = conn.CreateCommand();
                conn.Open();
                cmd.CommandText = string.Format("select * from CarReservationData where BookingItemID = {0}", bookingItemID);
                sdaAdapter      = new SqlDataAdapter(cmd);
                scbBuilder      = new SqlCommandBuilder(sdaAdapter);
                sdaAdapter.Fill(dsSet, "CarReservationData");
                //update the table value with the byte
                //byte [] reservationDode = FastInfoSetSerializer.ObjectToByteArray(expectedCarReservation);

                MemoryStream xmlMemory = XMLSerializer.Serialize(expectedCarReservation, typeof(CarReservation));
                MemoryStream FI_steam  = FastInfoSetSerializer.Serialize(xmlMemory);
                dsSet.Tables["CarReservationData"].Rows[0]["CarReservationNodeData"] = FI_steam.ToArray();
                //Post the data modification to the database.
                sdaAdapter.Update(dsSet, "CarReservationData");

                Console.WriteLine("CarReservationData updated successfully");
                conn.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("***********************************************************************");
                Console.WriteLine("occured an exception when update CarReservationData table :" + e.Message);
                Console.WriteLine("***********************************************************************");
                throw;
            }

            // Get the carReservation from EBL table CarReservationData
            CarReservationData carReservationData2     = CarBSDB.getCarReservationData(int.Parse(bookingItemID));
            CarReservation     expectedCarReservation2 = (CarReservation)FastInfoSetSerializer.DeserializeFIInDB((byte[])carReservationData2.CarReservationNodeData, typeof(CarReservation));
        }
 public ActionResult Edit([Bind(Include = "Id,DtTrx,CarUnitId,DtStart,LocStart,DtEnd,LocEnd,BaseRate,Destinations,UseFor,RenterName,RenterCompany,RenterEmail,RenterMobile,RenterAddress,RenterFbAccnt,RenterLinkedInAccnt,EstHrPerDay,EstKmTravel")] CarReservation carReservation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carReservation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CarUnitId = new SelectList(db.CarUnits, "Id", "Description", carReservation.CarUnitId);
     return(View(carReservation));
 }
예제 #24
0
        public bool BookACar(CarReservation reservation)
        {
            if (reservedCars.FirstOrDefault(c => (c.Car.Id == reservation.Car.Id && ((reservation.From >= c.From && reservation.From <= c.To) ||
                                                                                     (reservation.To <= c.To && reservation.To >= c.From)))) != null)
            {
                return(false);
            }

            reservedCars.Add(reservation);
            return(true);
        }
예제 #25
0
        private CarReservation CreateReservation()
        {
            var carR = new CarReservation();

            carR.Car         = SelectedCar;
            carR.Pickup      = ProposedViewModel.PickupLocation;
            carR.Destination = ProposedViewModel.DropoffLocation;
            carR.From        = ProposedViewModel.PickupDay;
            carR.To          = ProposedViewModel.DropoffDay;
            return(carR);
        }
예제 #26
0
        private void CreateCarReservation()
        {
            CarReservationSeed = CarReservationBuilder.Start().WithCustomer(CustomerBuilder.Start().Build()).Build();
            //CarReservationSeed.SetId();

            //foreach (var customer in CarReservationSeed.CarCustomers)
            //{
            //    customer.SetId();
            //}

            CarReservationSeed = _context.CarReservation.Add(CarReservationSeed).Entity;
        }
예제 #27
0
        public static CarReservationBuilder Start()
        {
            _carReservation = new CarReservation()
            {
                Name       = "Reserva de carro",
                InputDate  = DateTime.Now,
                OutputDate = DateTime.Now.AddDays(10),
                Car        = CarBuilder.Start().Build(),
                CarReservationCustomers = new List <Domain.Features.Flights.Customer>()
            };

            return(new CarReservationBuilder());
        }
        public int linkQuotation(int rsvId, int jobId)
        {
            try{
                CarReservation rsv = db.CarReservations.Find(rsvId);
                rsv.JobRefNo = jobId;

                db.Entry(rsv).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex) {
                return(1);
            }
            return(0);
        }
        // GET: CarReservations/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarReservation carReservation = db.CarReservations.Find(id);

            if (carReservation == null)
            {
                return(HttpNotFound());
            }
            return(View(carReservation));
        }
예제 #30
0
        // GET: CarReservations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CarReservation carReservation = _carReservationRepository.GetWhere(i => i.Id == id.Value).FirstOrDefault();

            if (carReservation == null)
            {
                return(HttpNotFound());
            }
            return(View(carReservation));
        }