Exemplo n.º 1
0
        public ActionResult <ParkingSpaceDetailDTO> UpdateParkingSpace(long id, [FromBody] ParkingSpace updatedParkingSpace)
        {
            var parkingSpace       = this.parkingSpaceRepository.UpdateParkingSpace(id, updatedParkingSpace);
            var parkingSpaceResult = this.mapper.Map <ParkingSpaceDetailDTO>(parkingSpace);

            return(parkingSpaceResult);
        }
        public void Take_ShouldBeNotAvailable()
        {
            ParkingSpace sut = new ParkingSpace();

            sut.Take();
            Assert.That(sut.GetIsAvailable(), Is.EqualTo(false));
        }
Exemplo n.º 3
0
        async void GetInfo()
        {
            ParkingSpace parkingSpace = await busCon.GetParkingSpace(bus.BusID.ToString());

            parkeerLbl.Text = "Parkeer op " + parkingSpace.Type.ToString() + parkingSpace.Number.ToString();
            await busCon.UpdateBus(bus, parkingSpace);
        }
        public void Take_ShouldBeFalse()
        {
            ParkingSpace sut = new ParkingSpace();

            sut.Take();
            Assert.That(sut.Take(), Is.EqualTo(false));
        }
Exemplo n.º 5
0
 public bool Parkvehicle(Vehicle vehicle, ParkingType parkingType)
 {
     if (!IsFull)
     {
         ParkingSpace availableSpace = AvailableSpaces.Where(p => p.Type == parkingType).OrderBy(p => p).FirstOrDefault();
         if (availableSpace != null)
         {
             availableSpace.Vehicle    = vehicle;
             availableSpace.IsOccupied = true;
             UsedSpaces.Add(availableSpace);
             AvailableSpaces.Remove(availableSpace);
             if (UsedSpaces.Count == MAX_SLOT)
             {
                 IsFull = true;
             }
             IsEmpty = false;
             return(true);
         }
         return(false);
     }
     else
     {
         Console.WriteLine("Parking is Full");
         return(false);
     }
 }
Exemplo n.º 6
0
        public async Task <ParkingSpace> GetParkingSpace(string id)
        {
            string       path         = "bus/giveparkingspace?id=" + id;
            ParkingSpace parkingSpace = await PostParkingSpaceAsync(path);

            return(parkingSpace);
        }
Exemplo n.º 7
0
    public void TestPark()
    {
        if (Random.Range(0.0f, 100.0f) < parkChance_)
        {
            Road         road    = car_.GetCurRoad().GetComponent <Road>();
            ParkingSpace parking = null;
            if (road)
            {
                GameObject space = road.GetParkingSpace();
                if (space)
                {
                    parking = space.GetComponent <ParkingSpace>();
                }
            }

            if (parking)
            {
                car_.SetState(CarState.CS_PARKING);
                parking.SetAvailable(false);

                car_.ClearTargets();
                List <Vector3> newTargets = parking.GetEnterTargets();
                foreach (Vector3 target in newTargets)
                {
                    car_.AddTarget(target);
                }

                curParking_ = parking;
            }
        }
    }
Exemplo n.º 8
0
        public string registerParkingSpace(ParkingSpace objParkingSpace)
        {
            string objMesaje = "-1";

            try
            {
                using (ParkingDataClassesDataContext sql = new ParkingDataClassesDataContext(cadenaConexion))
                {
                    parkingSpace objparkingSpace = new parkingSpace
                    {
                        parkingSpaceID = objParkingSpace.parkingSpaceID,
                        parkingLotID   = objParkingSpace.parkingLotID,
                        shortName      = objParkingSpace.shortName,
                        status         = true,
                    };
                    sql.parkingSpaces.InsertOnSubmit(objparkingSpace);
                    sql.SubmitChanges();
                    objMesaje = "0";
                };
            }
            catch (Exception ex)
            {
                objMesaje = ex.Message;
            }
            return(objMesaje);
        }
        public void Vacate_ShouldBeTrue()
        {
            ParkingSpace sut = new ParkingSpace();

            sut.Vacate();
            Assert.That(sut.GetIsAvailable(), Is.EqualTo(true));
        }
Exemplo n.º 10
0
        public IActionResult AddParkingSpace(ParkingLevelAddParkingSpaceViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var level = _levelRepository.GetById(viewModel.ParkingLevelId);

            if (level == null)
            {
                return(NotFound());
            }

            var parkingSpace = new ParkingSpace(viewModel.Number);
            var result       = level.AddParkingSpace(parkingSpace);

            if (!result.IsSuccess)
            {
                return(BadRequest(result.ErrorMessage));
            }

            _context.SaveChanges();
            return(RedirectToAction(nameof(ParkingController.Edit), "Parking", new { id = level.Parking.Id }));
        }
Exemplo n.º 11
0
        public string updteParkingSpace(ParkingSpace objParkingSpace)
        {
            string objMesaje = "-1";

            try
            {
                using (var sql = new ParkingDataClassesDataContext(cadenaConexion))
                {
                    var objparkingSpace = sql.parkingSpaces.Single(x => x.parkingSpaceID == objParkingSpace.parkingSpaceID);

                    objparkingSpace.parkingLotID   = objParkingSpace.parkingLotID;
                    objparkingSpace.parkingSpaceID = objParkingSpace.parkingSpaceID;
                    objparkingSpace.shortName      = objParkingSpace.shortName;
                    objparkingSpace.status         = objParkingSpace.status;

                    sql.SubmitChanges();
                    objMesaje = "0";
                };
            }
            catch (Exception ex)
            {
                objMesaje = ex.Message;
            }
            return(objMesaje);
        }
Exemplo n.º 12
0
        private async void FreeParkingSpaces_AddNew()
        {
            Days day           = new Days();
            var  listFreeDates = await OwnerFreeSpaces();

            var listBlackoutDates = await ListBlackout();

            var listWorkingDays = day.WorkingDays(_dateFrom, _dateTo).ToList();

            var freeDatesToDelete = from free in listFreeDates select Date.Format(free.Date);

            var blackoutDatesToDelete = from black in listBlackoutDates select Date.Format(black.Date);

            var dateToInsert = (from work in listWorkingDays
                                where
                                !freeDatesToDelete.Contains(Date.Format(work.Date))
                                &&
                                !blackoutDatesToDelete.Contains(Date.Format(work.Date))

                                select Date.Format(work.Date)).ToList();

            ParkingEntities1 d = new ParkingEntities1();

            foreach (var item in dateToInsert)
            {
                ParkingSpace p = new ParkingSpace();
                p.Date = item;
                p.ParkingSpaceOwnerID = _ownerId;
                p.Added = DateTime.Now;

                pe.ParkingSpaces.Add(p);
                pe.SaveChanges();
            }
        }
Exemplo n.º 13
0
        public ParkingSpace GetlParkingSpaceById(int id)
        {
            ParkingSpace singleParkingSpace = GetAllPrice()
                                              .FirstOrDefault(x => x.Id == id);

            return(singleParkingSpace);
        }
Exemplo n.º 14
0
    public void ToggleParkingSpaceIndicator(ParkingSpace ps, bool enable)
    {
        Transform  psTrf = parkingSpaceGoMap[ps].transform;
        GameObject area  = psTrf.Find("Area").gameObject;

        area.SetActive(enable);
    }
Exemplo n.º 15
0
        public ParkingSpace CreateParkingSpace(ParkingSpace c)
        {
            this.context.ParkingSpaces.Add(c);
            this.context.SaveChanges();

            return(c);
        }
Exemplo n.º 16
0
        protected override void RunActualProcess()
        {
            SqlConnection.RecreateTable <ParkingSpace>(Stage.Houses, Constants.PresentSlice);
            var dbHouses   = SqlConnection.GetDatabaseConnection(Stage.Houses, Constants.PresentSlice).Database;
            var households = dbHouses.Fetch <Household>();
            //var houses = dbHouses.Fetch<House>();
            var cars = dbHouses.Fetch <Car>();

            dbHouses.BeginTransaction();
            foreach (var car in cars)
            {
                var household = households.Single(x => x.HouseholdGuid == car.HouseholdGuid);
                var ps        = new ParkingSpace(car.HouseholdGuid, Guid.NewGuid().ToString(), car.HouseGuid, household.HausAnschlussGuid, household.Name + " car")
                {
                    CarGuid = car.CarGuid
                };
                if (car.CarType == CarType.Electric)
                {
                    ps.ChargingStationType = ChargingStationType.ThreekW;
                }
                else
                {
                    ps.ChargingStationType = ChargingStationType.NoCharging;
                }

                dbHouses.Save(ps);
            }

            dbHouses.CompleteTransaction();
        }
Exemplo n.º 17
0
        public ActionResult Create([Bind(Include = "Id,RegNum,Color,CheckInTime,NumOfTires,Model,ParkingSpaceNum,TypeId,MemberId, MembershipNr")] Vehicle vehicle)
        {
            vehicle.CheckInTime = DateTime.Now;
            if (ModelState.IsValid)
            {
                ParkingSpace ps    = new ParkingSpace(parkingCapacity);
                var          index = ps.AssignParkingSpace(vehicle);
                if (index != -1)
                {
                    ViewBag.isFull          = "";
                    vehicle.ParkingSpaceNum = index;
                    vehicle.MemberId        = db.Members.FirstOrDefault(v => v.MembershipNr == vehicle.MembershipNr).MemberId;
                    db.Vehicles.Add(vehicle);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.isFull = "There is no place to park your vehicle, sorry!";
                }
            }

            ViewBag.MemberId = new SelectList(db.Members, "MemberId", "MembershipNr", vehicle.MemberId);
            ViewBag.TypeId   = new SelectList(db.VehicleTypes, "TypeId", "Type", vehicle.TypeId);
            return(View(vehicle));
        }
        public ActionResult <ParkingSpace> Create(ParkingSpace c)
        {
            var parkingSpace = this.mapper.Map <ParkingSpace>(c);

            parkingSpace = this.parkingSpaceRepository.Create(parkingSpace);
            return(this.mapper.Map <ParkingSpace>(parkingSpace));
        }
        public void UpdateParkingSpace(int id, ParkingSpace parkingSpace)
        {
            var updateParkingSpace = _context.ParkingSpaces.SingleOrDefault(pl => pl.Id == id);

            CopyClass.CopyParkingSpace(parkingSpace, updateParkingSpace);
            _context.ParkingSpaces.Update(updateParkingSpace);
            Save();
        }
Exemplo n.º 20
0
        public void Should_Not_Release_ParkingSpace_And_Return_Unavailable()
        {
            var parkingSpace = new ParkingSpace(ParkingSpaceType.Car);

            parkingSpace.Occupy(2);

            Assert.False(parkingSpace.IsAvailable());
        }
Exemplo n.º 21
0
        public void Should_Occupy_ParkingSpace_And_Then_Be_Not_Available()
        {
            var parkingSpace = new ParkingSpace(ParkingSpaceType.Car);

            parkingSpace.Occupy(2);

            Assert.False(parkingSpace.IsAvailable());
        }
Exemplo n.º 22
0
        public ActionResult DeleteConfirmed(int id)
        {
            ParkingSpace parkingSpace = db.ParkingSpaces.Find(id);

            db.ParkingSpaces.Remove(parkingSpace);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 23
0
        public ParkingSpace UpdateParkingSpace(long id, ParkingSpace newParkingSpace)
        {
            newParkingSpace.Id = id;
            this.context.Entry(newParkingSpace).State = EntityState.Modified;
            this.context.SaveChanges();

            return(newParkingSpace);
        }
Exemplo n.º 24
0
        public async Task <bool> UpdateBus(Bus bus, ParkingSpace parkingSpace)
        {
            string path = "parkingspace/updateoccupied";

            await PostUpdateParkingSpaceAsync(path, parkingSpace.ParkingSpaceID, bus.BusID, true);

            return(await PostUpdateParkingSpaceAsync(path, bus.ParkingSpace, 0, false));
        }
Exemplo n.º 25
0
        public void Should_Load_Entity_Correctly()
        {
            var parkingSpace = new ParkingSpace(ParkingSpaceType.Car);

            var expected = ParkingSpaceType.Car;

            Assert.Equal(expected, parkingSpace.Type);
        }
 public static ParkingSpaceViewModel ToParkingSpaceViewModel(this ParkingSpace parkingSpace)
 {
     return(new ParkingSpaceViewModel
     {
         Id = parkingSpace.Id,
         Number = parkingSpace.Number,
         Status = parkingSpace.Status
     });
 }
Exemplo n.º 27
0
        public void Should_Release_ParkingSpace_And_Then_Be_Available()
        {
            var parkingSpace = new ParkingSpace(ParkingSpaceType.Car);

            parkingSpace.Occupy(2);
            parkingSpace.Release();

            Assert.True(parkingSpace.IsAvailable());
        }
Exemplo n.º 28
0
 public static void CopyParkingSpace(ParkingSpace source, ParkingSpace destination)
 {
     destination.Details      = source.Details;
     destination.HasCarWash   = source.HasCarWash;
     destination.IsCovered    = source.IsCovered;
     destination.IsTaken      = source.IsTaken;
     destination.Name         = source.Name;
     destination.ParkingLotId = source.ParkingLotId;
     destination.Price        = source.Price;
 }
Exemplo n.º 29
0
        public IActionResult Post([FromBody] ParkingSpace parkingSpace)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var record = service.SaveOneParkingSpace(parkingSpace);

            return(Created("api/parkingSpace/:id" + parkingSpace.Id, parkingSpace));
        }
        public int AddParkingSpace(ParkingSpace pSpace)
        {
            using (ParkingSystemContext Ctx = new ParkingSystemContext())
            {
                Ctx.ParkingSpaces.Add(pSpace);
                Ctx.SaveChanges();
            }

            return(pSpace.Id);
        }
Exemplo n.º 31
0
 public async Task<bool> VendorRegistrationNotification(ParkingSpace parkingSpace)
 {
     var param = new string[] { parkingSpace.Email, parkingSpace.Address };
     var emailToAdminBody = GetMessage(param, System.Web.Hosting.HostingEnvironment.MapPath("~/EmailTemplates/NewVendorRegistration.html"));
     var emailToAdminReceiver = new List<string>();
     emailToAdminReceiver.Add("*****@*****.**");
     emailToAdminReceiver.Add("*****@*****.**");
     emailToAdminReceiver.Add("*****@*****.**");
     var emailToAdmin = new EmailNotification
     {
         From = "*****@*****.**",
         To = emailToAdminReceiver,
         Subject = "Parko - new vendor registration",
         Message = emailToAdminBody,
         IsHtml = true,
         Status = 1
     };
     await EmailRepository.CreateSync(emailToAdmin);
     return true;
 }
Exemplo n.º 32
0
 public async Task<bool> VendorRegistrationSendToVendor(ParkingSpace parkingSpace)
 {
     var param = new string[] { parkingSpace.Email, parkingSpace.Address };
     var emailToAdminBody = GetMessage(param, System.Web.Hosting.HostingEnvironment.MapPath("~/EmailTemplates/VendorRegistration.html"));
     var emailToAdminReceiver = new List<string>();
     emailToAdminReceiver.Add(parkingSpace.Email);
     var bcc = new List<string>();
     bcc.Add("*****@*****.**");
     var emailToAdmin = new EmailNotification
     {
         From = "*****@*****.**",
         To = emailToAdminReceiver,
         Subject = "Welcome to Parko!",
         Bcc = bcc,
         Message = emailToAdminBody,
         IsHtml = true,
         Status = 1
     };
     await EmailRepository.CreateSync(emailToAdmin);
     return true;
 }