private FloorModel MapFloor(FloorEntity floorEntity) { List <FloorItemBanner> bannerList = FloorHelper.GetFloorItem <FloorItemBanner>(floorEntity).OrderBy(x => x.Priority).ToList(); List <FloorItemProduct> productList = FloorHelper.GetFloorItem <FloorItemProduct>(floorEntity).OrderBy(x => x.Priority).ToList(); FloorModel model = new FloorModel(); //楼层基本信息 model.Name = floorEntity.FloorName; //banner var banner = bannerList.FirstOrDefault(); if (banner != null) { model.Banner.BannerResourceUrl = banner.ImageSrc; model.Banner.BannerTitle = banner.BannerText; model.Banner.BannerLink = banner.LinkUrl; //从BannerLink中提取相关信息(比如ProductSysNo等) BannerHelper.FillPromoInfo(model.Banner); } //推荐商品列表 ImageSize imageSize = ImageUrlHelper.GetImageSize(ImageType.Small); for (int i = 0; i < 3 && i < productList.Count; i++) { var item = productList[i]; var floorItemModel = MapFloorItem(item, imageSize); model.ItemList.Add(floorItemModel); } return(model); }
public ActionResult Create(FloorEntity model) { model.Id = null; model.OrganizationId = CurrentOrganization.Id; _floorRepository.Update(model); return(RedirectToAction("Index")); }
public virtual bool ParkingPlaceAvailabe(FloorEntity floor, BookingEntity booking) { if (floor.CountEmptyPlaces >= 1 || booking.ArrivalTime < floor.NextEmptyPlace) { return(false); } return(false); }
public void Delete(FloorEntity floor) { if (floor.ID != 0) { _floorRepository.Detele(floor.ID); } else { throw new Exception("Nothing to delete!"); } }
public void SaveBooking(BookingEntity booking) { FloorEntity floor = new FloorEntity(); CarEntity car = new CarEntity(); if ((ParkingPlaceAvailabe(floor, booking) == true) && booking.ID == 0 && floor.BookedPlace == "empty") { _bookingRepository.Insert(booking); } else if (CheckBookingNo(booking, car) == true) { _bookingRepository.Update(booking); } }
public void SaveFloor(FloorEntity floorEntity) { BookingEntity booking = new BookingEntity(); CarEntity car = new CarEntity(); if ((ParkingPlaceAvailabe(floorEntity, booking) == true) && floorEntity.ID == 0 && floorEntity.BookedPlace == "empty") { _floorRepository.Insert(floorEntity); } else if (CheckBookingNo(booking, car) == true) { _floorRepository.Update(floorEntity); } }
public Floor ConvertToFloor(FloorEntity floorEntity) { var floor = new Floor(); floor.ID = floorEntity.ID; floor.NextEmptyPlace = floorEntity.NextEmptyPlace; floor.BookedPlace = floorEntity.BookedPlace; floor.CountCarsParked = floorEntity.CountCarsParked; floor.CountEmptyPlaces = floorEntity.CountEmptyPlaces; floor.CountReservedPlaces = floorEntity.CountReservedPlaces; floor.FloorNumber = floorEntity.FloorNumber; return(floor); }
//private readonly string connectionString; //public FloorController() => connectionString = ConfigurationManager.ConnectionStrings["ParkingData1"].ConnectionString; // GET: Floor //private readonly string connectionString; //public FloorController() => connectionString = ConfigurationManager.ConnectionStrings["ParkingData1"].ConnectionString; //public ActionResult FloorInfo(FloorModel model) //{ // SqlConnection sqlConnection = new SqlConnection(); // string path = ConfigurationManager.ConnectionStrings["ParkingData1"].ConnectionString; // sqlConnection.ConnectionString = path; // String sql = "SELECT * FROM Floor"; // SqlCommand cmd = new SqlCommand(sql, (sqlConnection)); // using (var connection = new SqlConnection(path)) // { // connection.Open(); // SqlDataReader sqlDataReader = cmd.ExecuteReader(); // } // return View(model); //public ActionResult Students() //{ // String connectionString = "<THE CONNECTION STRING HERE>"; // String sql = "SELECT * FROM students"; // SqlCommand cmd = new SqlCommand(sql, conn); // var model = new List<Student>(); // using (SqlConnection conn = new SqlConnection(connectionString)) // { // conn.Open(); // SqlDataReader rdr = cmd.ExecuteReader(); // while (rdr.Read()) // { // var student = new Student(); // student.FirstName = rdr["FirstName"]; // student.LastName = rdr["LastName"]; // student.Class = rdr["Class"]; // .... // model.Add(student); // } // } // return View(model); //FloorModel floorModel = new FloorModel(); //public ActionResult FloorInfo(int id=0) //{ // SqlConnection sqlConnection = new SqlConnection(); // string path = ConfigurationManager.ConnectionStrings["ParkingData1"].ConnectionString; // sqlConnection.ConnectionString = path; // DataTable dataTable = new DataTable(); // try // { // SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select * from Floor", sqlConnection); // sqlDataAdapter.Fill(dataTable); // } // catch (Exception) // { // throw new Exception("Connection to SQL failed"); // } // return View(dataTable); //} #endregion #region Private Methods private FloorEntity ConvertFromBLLToRepo(Floor floor) { var floorEntity = new FloorEntity(); { floorEntity.BookedPlace = floor.BookedPlace; floorEntity.CountCarsParked = floor.CountCarsParked; floorEntity.CountEmptyPlaces = floor.CountEmptyPlaces; floorEntity.CountReservedPlaces = floor.CountReservedPlaces; floorEntity.FloorNumber = floor.FloorNumber; floorEntity.ID = floor.ID; floorEntity.NextEmptyPlace = floor.NextEmptyPlace; } return(floorEntity); }
public ActionResult Edit(FloorEntity model) { var floor = _floorRepository.Get(model.Id); if (null == floor || floor.OrganizationId != CurrentOrganization.Id) { return(HttpNotFound()); } model.OrganizationId = CurrentOrganization.Id; // values to keep model.Image = floor.Image; model.CoordinatesInImage = floor.CoordinatesInImage; _floorRepository.Update(model); return(RedirectToAction("Index")); }
/// <summary> /// 获取楼层信息 /// </summary> /// <typeparam name="T">要获取的楼层信息类型</typeparam> /// <param name="floor">楼层数据</param> /// <returns></returns> public static List <T> GetFloorItem <T>(FloorEntity floor) where T : FloorItemBase, new() { List <T> result = new List <T>(); if (floor == null || floor.FloorSectionItems == null) { return(result); } List <FloorItemBase> brandList = floor.FloorSectionItems.FindAll(x => x is T); foreach (var entity in brandList) { result.Add(entity as T); } return(result); }
private RoomInfo BuildRoomInfo(string roomName, bool canControl, RoomMetadataEntity roomMetadata, BuildingEntity building, FloorEntity floor) { return(new RoomInfo() { CurrentTime = _dateTimeService.Now, DisplayName = (roomName ?? "").Replace("(Meeting Room ", "("), CanControl = canControl, Size = roomMetadata.Size, BuildingId = roomMetadata.BuildingId, BuildingName = building.Name, FloorId = roomMetadata.FloorId, Floor = floor.Number, FloorName = floor.Name, DistanceFromFloorOrigin = roomMetadata.DistanceFromFloorOrigin ?? new Point(), Equipment = roomMetadata.Equipment, HasControllableDoor = !string.IsNullOrEmpty(roomMetadata.GdoDeviceId), BeaconUid = roomMetadata.BeaconUid, }); }