public EditViewModel(ParkingPlace place, User user) { VType = new ObservableCollection <vtype>() { new vtype() { Title = "Автомобиль" }, new vtype() { Title = "Мотоцикл" }, }; PType = new ObservableCollection <ptype>() { new ptype() { Title = "Крытая" }, new ptype() { Title = "Открытая" }, }; U = user; SelectedPlace = place; Entry = SelectedPlace.Entrydate; Exit = SelectedPlace.Exitdate; CarNumber = SelectedPlace.Carnumber; Id = SelectedPlace.Id; }
public void ToggleStatus(Guid id) { ParkingPlace selectedplace = this.context.ParkingPlaces.FirstOrDefault(x => x.Id == id); selectedplace.Availability = !selectedplace.Availability; this.context.SaveChanges(); }
private void deleteCarButton_Click(object sender, EventArgs e) { ParkingPlace place = places.Where(x => x.PlacePanel.Tag == bluePanel.Tag).FirstOrDefault(); place.CarInPlace = null; UpdatePanelInformation(place); }
public ParkingPlaceForReservationInNotificationDTO(ParkingPlace parkingPlace) { Id = parkingPlace.Id; Location = new Location(parkingPlace.Location); Status = parkingPlace.Status; Zone = new Zone(parkingPlace.Zone); }
private void btnAdd_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { ParkingPlace PP = new ParkingPlace(); PP.ParkingName = txtParkingName.Text; string str = txtAddress.Text; str = str.Replace("\n", String.Empty); str = str.Replace("\r", String.Empty); str = str.Replace("\t", String.Empty); //MessageBox.Show(str); PP.Address = str; PP.TwoCapacity = Int32.Parse(txtTwoCapacity.Text); PP.FourCapacity = Int32.Parse(txtFourCapacity.Text); PP.TwoRate = Int32.Parse(txtTwoRate.Text); PP.FourRate = Int32.Parse(txtFourRate.Text); //MessageBox.Show(PP.ParkingName + "," + PP.Address + "," + PP.TwoCapacity + "," + PP.FourCapacity + "," + PP.TwoRate + "," + PP.FourRate + "."); db.ParkingPlaces.Add(PP); db.SaveChanges(); this.Hide(); Homepage home = new Homepage(aEmail); home.Show(); } }
public IActionResult Update(long id, ParkingPlace parking) { var slot = _context.Parking.Find(id); if (slot == null) { return(NotFound("Parking slot was not found")); } if (parking.UserId > 0) { slot.UserId = parking.UserId; } if (parking.StartDate != null) { slot.StartDate = parking.StartDate; } if (parking.EndDate != null) { slot.EndDate = parking.EndDate; } if (parking.Reserved != null) { slot.Reserved = parking.Reserved; } _context.Parking.Update(slot); _context.SaveChanges(); return(NoContent()); }
public ActionResult EditPlace(ParkingPlace aPlace) { PlaceService service = new PlaceService(); service.editPlace(aPlace, 10); return(RedirectToAction("index", "Owner")); }
public void AddNewCar(Car car) { ParkingPlace place = places.Where(x => x.PlacePanel.Tag == bluePanel.Tag).FirstOrDefault(); place.CarInPlace = car; UpdateBindings(); UpdatePanelInformation(place); }
public async Task <HttpResponseMessage> LeaveParkingPlace(Dto value) { string token = GetHeader("token"); if (token == null || (token != null && !TokenManager.ValidateToken(token))) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } User loggedUser = usersService.GetLoggedUser(token); bool paidParkingPlaceFoundedAndRemoved = paidParkingPlacesService.RemovePaidParkingPlace(loggedUser, value.ParkingPlaceId); if (paidParkingPlaceFoundedAndRemoved) { Zone zone = null; try { zone = zonesService.GetZone(value.ZoneId); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message)); } ParkingPlace parkingPlace = null; try { parkingPlace = zone.ParkingPlaces .Where(pp => pp.Id == value.ParkingPlaceId) .Single(); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message)); } lock (parkingPlace) { if (parkingPlace.Status != ParkingPlaceStatus.TAKEN) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "parkingPlace.Status == ParkingPlaceStatus.TAKEN")); } parkingPlace.Status = ParkingPlaceStatus.EMPTY; lock (parkingPlace.Zone) { parkingPlace.Zone.Version++; parkingPlace.Zone.AddParkingPlaceChange(parkingPlace.Id, parkingPlace.Status); } } return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public ParkingPlaceDTO UpdatePlace(int id, ParkingPlaceDTO place) { var identityModel = new ParkingPlaceIdentityModel(id); var updateModel = Mapper.Map <ParkingPlaceUpdateModel>(place); ParkingPlace res = PlaceUpdateService.UpdateParkingPlace(identityModel, updateModel); return(Mapper.Map <ParkingPlaceDTO>(res)); }
public int createPlace(ParkingPlace aParkingPlace) { PsDbContex db = new PsDbContex(); var x = db.ParkingPlaces.Add(aParkingPlace); db.SaveChanges(); return(x.ID); }
private IdealResultClass populateIdealClass(ParkingPlace x) { return(new IdealResultClass { Id = x.Id, Availability = x.Availability, Name = x.Name }); }
//ParkingPlaceRepository parkingPlaceRepository = new ParkingPlaceRepository(); public ParkingPlaceDTO ParkingPlaceToParkingPlaceDTO(ParkingPlace parkingPlace) { ParkingPlaceDTO parkingPlaceDTO = new ParkingPlaceDTO(); parkingPlaceDTO.Number = parkingPlace.Number; ParkingTicketMapper parkingTicketMapper = new ParkingTicketMapper(); parkingPlaceDTO.Ticket = parkingTicketMapper.ParkingTicketToParkingTicketDTO(parkingPlace.Ticket); return(parkingPlaceDTO); }
private static Rectangle GetRectangle(ParkingPlace p, int placeHeight, int placeWidth) { const int offsetX = 10; const int offsetY = 10; return new Rectangle( (p.Column - 1) * placeWidth + offsetX, (p.Row - 1) * placeHeight + offsetY, placeWidth - offsetX, placeHeight - offsetY); }
public void AddToParking(string carPlate) { var parkingPlace = new ParkingPlace { ArrivedAt = DateTime.Now, CarPlate = carPlate }; _parkingPlaces.Insert(parkingPlace); }
public ActionResult DeletePlace(int id) { using (MyDatabaseEntities db = new MyDatabaseEntities()) { ParkingPlace pp = db.ParkingPlace.Where(x => x.Id == id).FirstOrDefault <ParkingPlace>(); db.ParkingPlace.Remove(pp); db.SaveChanges(); return(Json(new { success = true, message = "Place Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public ParkingPlace getPlaceInfo(int id) { PsDbContex db = new PsDbContex(); ParkingPlace el = new ParkingPlace() { SpotName = "DEBUG" }; el = db.ParkingPlaces.SingleOrDefault(r => r.ID == id); //if (el == null) return el; return(el); }
public ActionResult Bookings() { List <Booking> books = new List <Booking>(); UserBookingService bservice = new UserBookingService(); int id = Convert.ToInt32(Session["USERID"]); books = bservice.getAllBookings(id); //return books[0].PlaceId.ToString(); List <Subscriptions> sub = new List <Subscriptions>(); sub = bservice.GetAllSubscriptions(id); List <UserBookingModel> data = new List <UserBookingModel>(); PlaceService pserv = new PlaceService(); for (int i = 0; i < books.Count; i++) { ParkingPlace pl = new ParkingPlace(); pl = pserv.getPlaceInfo(books[i].PlaceId); //return pl.SpotName.ToString(); UserBookingModel mod = new UserBookingModel(); mod.Name = pl.SpotName; mod.PlaceId = pl.ID; mod.IsPending = books[i].IsPending; mod.Price = pl.PricePerHour; mod.idBook = 1; //means book type data.Add(mod); } for (int i = 0; i < sub.Count; i++) { ParkingPlace pl = new ParkingPlace(); pl = pserv.getPlaceInfo(sub[i].PlaceId); UserBookingModel mod = new UserBookingModel(); mod.Name = pl.SpotName; mod.PlaceId = pl.ID; mod.Price = pl.PricePerHour; mod.idBook = 0; //means subs type mod.Date = sub[i].End; data.Add(mod); } //return "none"; return(View("bookings", data)); }
public List <ParkingPlace> getPlaceInfo2(int id) { PsDbContex db = new PsDbContex(); ParkingPlace el = db.ParkingPlaces.SingleOrDefault(r => r.ID == id); List <ParkingPlace> li = new List <ParkingPlace>(); li.Add(el); if (el == null) { return(li); } return(li); }
public bool deletePlace(int aPlaceId) { PsDbContex db = new PsDbContex(); ParkingPlace el = db.ParkingPlaces.SingleOrDefault(r => r.ID == aPlaceId); if (el == null) { return(false); } db.ParkingPlaces.Remove(el); db.SaveChanges(); return(true); }
public void UpdateP() { try { sqlCon.Open(); AdminCollection.Clear(); string statusr = "******"; SqlCommand running = new SqlCommand(statusr, sqlCon); running.CommandType = CommandType.Text; running.Parameters.AddWithValue("@statusr", "Заезд подтвержден"); running.ExecuteNonQuery(); string statusd = "UPDATE ParkingPlace SET Status = @statusd WHERE ExitDate < GETDATE()"; SqlCommand done = new SqlCommand(statusd, sqlCon); done.CommandType = CommandType.Text; done.Parameters.AddWithValue("@statusd", "Бронирование завершено"); done.ExecuteNonQuery(); string sql = "SELECT EnterDate, ExitDate, CarNumber, VehicleType, ParkingType, Price, Username, Status, Id FROM ParkingPlace ORDER BY Status"; SqlCommand command = new SqlCommand(sql, sqlCon); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ParkingPlace place = new ParkingPlace(); place.Entrydate = reader.GetDateTime(0); place.Exitdate = reader.GetDateTime(1); place.Carnumber = reader.GetString(2); place.Vehicletype = reader.GetString(3); place.Parkingtype = reader.GetString(4); place.Price = reader.GetInt32(5); place.Username = reader.GetString(6); place.Status = reader.GetString(7); place.Id = reader.GetInt32(8); AdminCollection.Add(place); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (sqlCon != null) { sqlCon.Close(); } } }
//Newly Added.. public ActionResult Search(int id) { PlaceService service = new PlaceService(); ParkingPlace matches = new ParkingPlace(); FacilityService fs = new FacilityService(); string dsc = fs.getFacility(id); matches = service.getPlaceInfo(id); ReviewService rs = new ReviewService(); CompareViewModel data = new CompareViewModel() { Name = matches.SpotName, PlaceId = matches.ID, Price = matches.PricePerHour, Rating = rs.getRating(id), Facilities = dsc }; string name = "matches"; int _cnt = Convert.ToInt32(Session["cnt"]); int lim = Convert.ToInt32(Session["lim"]); if (lim >= 4) { return(RedirectToAction("compare", "users")); } _cnt++; Session["cnt"] = _cnt.ToString(); lim++; Session["lim"] = lim.ToString(); Session[name + _cnt.ToString()] = data; //List<ParkingPlace> model = new List<ParkingPlace>(); //for(int i=1;i<=_cnt;i++) //{ // if ((Session[name + i.ToString()]).ToString() == "none") continue; // ParkingPlace p = (ParkingPlace)Session[name + i.ToString()]; // model.Add(p); //} //return View("compare", model); return(RedirectToAction("compare", "users")); }
public bool approvePlace(int aPlaceId) { // Caution: Update May Not Work.. PsDbContex db = new PsDbContex(); ParkingPlace el = db.ParkingPlaces.SingleOrDefault(r => r.ID == aPlaceId); if (el == null) { return(false); } el.IsBlocked = 0; db.SaveChanges(); return(true); }
public ActionResult AddPlace(ParkingPlace pp) { using (MyDatabaseEntities db = new MyDatabaseEntities()) { if (pp.Id == 0) { db.ParkingPlace.Add(pp); db.SaveChanges(); return(Json(new { success = true, message = "Place Saved Successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(pp).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "Place Updated Successfully" }, JsonRequestBehavior.AllowGet)); } } }
public void TestDeletePlace() { Mock <IParkingPlaceDataAccess> parkingPlaceDataAccess = new Mock <IParkingPlaceDataAccess>(); ParkingPlace expected = new ParkingPlace() { Flor = 1, Number = 1, PersonId = 1, Auto = "Lada" }; parkingPlaceDataAccess.Setup(x => x.Insert(It.IsAny <ParkingPlaceUpdateModel>())).Returns(expected); var placeCreateService = new ParkingPlaceDeleteService(parkingPlaceDataAccess.Object); placeCreateService.DeleteParkingPlace(new ParkingPlaceIdentityModel(1)); parkingPlaceDataAccess.Verify(x => x.Delete(It.IsAny <ParkingPlaceIdentityModel>()), Times.Once()); }
private void UpdatePanelInformation(ParkingPlace place) { List <Label> labels = new List <Label>(); if (place.CarInPlace != null) { foreach (object obj in place.PlacePanel.Controls) { if (obj is PictureBox box) { box.Image = place.CarInPlace.Image; } if (obj is Label label) { labels.Add(label); } } labels[1].Text = place.CarInPlace.Name; labels[0].Text = "№ " + place.CarInPlace.Number; } else { foreach (object obj in place.PlacePanel.Controls) { if (obj is PictureBox box) { box.Image = null; } if (obj is Label label) { label.Text = "нет данных"; } } } foreach (Label label in labels) { label.Visible = true; } bluePanel.BackColor = Color.MediumSeaGreen; bluePanel = null; }
public void TestGetPlace() { Mock<IParkingPlaceDataAccess> parkingPlaceDataAccess = new Mock<IParkingPlaceDataAccess>(); ParkingPlace expected = new ParkingPlace() { Flor = 1, Number = 1, PersonId = 1, Auto = "Lada" }; parkingPlaceDataAccess.Setup(x => x.Get(It.IsAny<ParkingPlaceIdentityModel>())).Returns(expected); var getService = new ParkingPlaceGetService(parkingPlaceDataAccess.Object); ParkingPlace place = getService.Get(new ParkingPlaceIdentityModel(1)); Assert.AreEqual(place.Flor, expected.Flor); Assert.AreEqual(place.PersonId, expected.PersonId); Assert.AreEqual(place.Auto, expected.Auto); Assert.AreEqual(place.Number, expected.Number); }
public int editPlace(ParkingPlace aParkingPlace, int aPlaceId) { // Caution: Update May Not Work.. PsDbContex db = new PsDbContex(); ParkingPlace el = db.ParkingPlaces.SingleOrDefault(r => r.ID == aParkingPlace.ID); if (el == null) { return(0); } el.SpotName = aParkingPlace.SpotName; el.SpotLocation = aParkingPlace.SpotLocation; el.PricePerHour = aParkingPlace.PricePerHour; el.Capacity = aParkingPlace.Capacity; db.SaveChanges(); return(1); }
//get all parking places from webservice public void getAllParkingPlacesFromWebservice() { //clear list if (ParkingPlace == null) { ParkingPlace = new ObservableCollection <ParkingPlaceData>(); } else { ParkingPlace.Clear(); } Webservice Service = new Webservice(); Service.getAllParkingPlaces(); for (int i = 0; i < Service.ParkingPlaceList.Count; i++) { ParkingPlace.Add(Service.ParkingPlaceList.ElementAt(i)); } }
public void Initialize() { _parkingPlaceService = Substitute.For <IParkingPlaceService>(); _mapper = Substitute.For <AutoMapper.IMapper>(); _log = Substitute.For <Logger.IMapper>(); _parkingPlace = new ParkingPlace { IDParkingPlace = 1, Place = "dom" }; _parkingPlaceService.AllParkingPlace() .Returns(Task.FromResult((IEnumerable <ParkingPlace>) new List <ParkingPlace>() { _parkingPlace }) ); _parkingPlaceService.FindById(Arg.Is <int>(x => x == 1)) .Returns(_parkingPlace); }
public void TestCreatePlace() { Mock <IParkingPlaceDataAccess> parkingPlaceDataAccess = new Mock <IParkingPlaceDataAccess>(); ParkingPlace expected = new ParkingPlace() { Flor = 1, Number = 1, PersonId = 1, Auto = "Lada" }; parkingPlaceDataAccess.Setup(x => x.Insert(It.IsAny <ParkingPlaceUpdateModel>())).Returns(expected); var placeCreateService = new ParkingPlaceCreateService(parkingPlaceDataAccess.Object); ParkingPlace place = placeCreateService.CreateParkingPlace(new ParkingPlaceUpdateModel() { Flor = 1, Number = 1, PersonId = 1, Auto = "Lada" }); Assert.AreEqual(place.Flor, expected.Flor); Assert.AreEqual(place.Number, expected.Number); Assert.AreEqual(place.Auto, expected.Auto); Assert.AreEqual(place.PersonId, expected.PersonId); }
private Pen GetPen(ParkingPlace parkingPlace, int thickness) { return new Pen(GetColor(parkingPlace.ParkingPlaceType), thickness); }
private static Image GetImage(ParkingPlace parkingPlace) { if (parkingPlace.ParkingPlaceStatus == ParkingPlaceStatus.Reservated) return Image.FromFile("images/reservecar.png"); return Image.FromFile("images/busycar.png"); }
private Brush GetBrush(ParkingPlace parkingPlace) { return new SolidBrush(GetBrushColor(parkingPlace.ParkingPlaceStatus)); }