/// <summary> /// 根据搜索条件获取宿舍楼列表 /// </summary> /// <param name="webModel">宿舍楼列表页视图模型</param> /// <param name="context">数据库上下文对象</param> /// <returns></returns> public static async Task <List <Building> > GetListAsync(BuildingViewModel webModel, ApplicationDbContext context) { if (string.IsNullOrEmpty(webModel.SId) && webModel.SType == 0 && webModel.SEnable == 9) { return(await context.Set <Building>().AsNoTracking().Skip(webModel.Start).Take(webModel.Limit).OrderByDescending(i => i.CreatedOn).ToListAsync()); } else { IQueryable <Building> buildings = context.Building.AsQueryable(); var predicate = PredicateBuilder.New <Building>(); //宿舍楼编号 if (!string.IsNullOrEmpty(webModel.SId)) { predicate = predicate.And(i => i.Id == Convert.ToInt64(webModel.SId)); } //宿舍楼类型 if (webModel.SType != 0) { predicate = predicate.And(i => i.Type == webModel.SType); } //宿舍楼是否启用 if (webModel.SEnable != 9) { bool flag = webModel.SEnable == 1; predicate = predicate.And(i => i.IsEnabled == flag); } return(await buildings.AsExpandable().Where(predicate).ToListAsync()); } }
private void Lecturer_Page_Loaded(object sender, RoutedEventArgs e) { _lecturerViewModel = new LecturerViewModel(); _centerViewModel = new CenterViewModel(); _buildingViewModel = new BuildingViewModel(); _facultyViewModel = new FacultyViewModel(); _departmentViewModel = new DepartmentViewModel(); List <LecturerEntity> lecturers = _lecturerViewModel.LoadLecturerData(); lecturer_data_grid.ItemsSource = lecturers; center_combobx.ItemsSource = _centerViewModel.LoadCenterData(); building_combobx.ItemsSource = _buildingViewModel.LoadBuildingData(); faculty_combobx.ItemsSource = _facultyViewModel.LoadFacultyData(); department_combobx.ItemsSource = _departmentViewModel.LoadDepartmentData(); foreach (LecturerEntity l in lecturers) { lecturerIds.Add(l.EmployeeId); } add_btn_.IsEnabled = false; update_btn_.IsEnabled = false; delete_btn_.IsEnabled = false; emp_id_txtbx.Text = "Eg: 000150"; }
public virtual ActionResult Building(bool forceQuery = false) { if (forceQuery) { // We force the query to execute // TC1: Click Recalculate Carton Requirements link on the Building View try { _service.RefreshPullableCartons(); this.AddStatusMessage("Refresh has been initiated"); } catch (DbException ex) { ModelState.AddModelError("", ex.Message); } // We redirect because refresh of this page should not pass true again return(RedirectToAction(this.Actions.Building())); } var model = new BuildingViewModel { BuildingAreaChoiceList = from choice in _service.GetAreaList() select new BuildingAreaModel { BuildingId = choice.BuildingId, CartonAreaId = choice.CartonAreaId, CartonCount = choice.PullableCartonCount, PickAreaId = choice.AreaId, RestockAreaId = choice.RestockAreaId, ShortName = choice.ShortName } }; model.GenerateStats += new EventHandler <BuildingStatsEventArgs>(bvm_OnGenerateStats); return(View(Views.Building, model)); }
public MainViewModel() { items = new ObservableCollection <ItemMainMenu> { new ItemMainMenu("./img/rect.png", false, DisplayBuildingPage), new ItemMainMenu("./img/people.png", false, DisplayPeoplePage), new ItemMainMenu("./img/star.png", false, DisplayCriterionPage), new ItemMainMenu("./img/note.png", false, DisplayAlternativePage), new ItemMainMenu("./img/checkmark.png", false, DisplayPeoplePage), }; homePage = new HomePage(); buildingPage = new BuildingHierarchyPage(); peoplePage = new PeopleAssessmentsPage(); criterionPage = new CriterionAssessmentsPage(); alternativePage = new AlternativeAssessmentsPage(); buildingVM = new BuildingViewModel(); buildingPage.DataContext = buildingVM; buildingVM.Notify += GetFullInfo; mathResult = new MathResult(); EnabledMenu = false; SelectedIndexMenu = -1; CurrentPage = homePage; }
public List <BuildingViewModel> GetBuildings() { DBOperations dbOps = new DBOperations(); List <BuildingViewModel> objs = new List <BuildingViewModel>(); try { dbOps.ProcName = AppConstants.USP_GETBUILDINGS; dbOps.ExecuteReader(); if (!(dbOps.DataReader == null)) { using (dbOps.DataReader) { while (dbOps.DataReader.Read()) { BuildingViewModel obj = new BuildingViewModel { BuildingId = Helper.HandleDBNull <int>(dbOps.DataReader[8]), Name = Helper.HandleDBNull <string>(dbOps.DataReader[0]), Description = Helper.HandleDBNull <string>(dbOps.DataReader[1]), }; objs.Add(obj); } } } return(objs); } catch (Exception Ex) { throw Ex; } }
public async Task PostNewBuilding(BuildingViewModel buildingViewModel) { using CampFinderDbContext context = dbContextFactory.CreateDbContext(); await context.Buildings.AddAsync(mapper.Map <Building>(buildingViewModel)); await context.SaveChangesAsync(); }
public async Task <IActionResult> PutBuilding([FromRoute] int id, [FromBody] BuildingViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var building = new Building { Id = id, Name = model.Name }; _context.Entry(building).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuildingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// 搜索宿舍楼信息 /// </summary> /// <param name="webModel">列表页视图Model</param> /// <param name="context">数据库连接上下文对象</param> /// <returns></returns> public async Task <BuildingViewModel> SearchBuildingAsync(BuildingViewModel webModel, ApplicationDbContext context) { try { //Source Data List var list = await DormitoryRepository.GetListAsync(webModel, context); //Return Data List var dataList = new List <BuildingData>(); if (list != null && list.Any()) { dataList.AddRange(list.Select(item => new BuildingData { Id = item.Id.ToString(), Name = item.Name, Floor = item.Floor, Type = item.Type, CreatedName = item.CreatedName, DateTime = item.CreatedOn.ToString("yyyy-MM-dd"), IsEnabled = item.IsEnabled })); } webModel.BuildingList = dataList; webModel.Total = await DormitoryRepository.GetListCountAsync(webModel, context); } catch (Exception ex) { _logger.LogError("获取宿舍楼列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message); } return(webModel); }
// GET: ResidentialBuilding public ActionResult Index() { BuildingViewModel model = new BuildingViewModel(); model.ResidentialBuildings = db.ResidentialBuildings.ToList(); model.ResidentialLocations = db.ResidentialLocations.ToList(); return(View(model)); }
public ActionResult AddEditBuilding(int BuildingId) { BuildingViewModel model = new BuildingViewModel(); if (BuildingId > 0) { model = repo.BuildingById(BuildingId); } return(PartialView("AddEditBuilding", model)); }
private void Page_Loaded(object sender, RoutedEventArgs e) { _buildingViewModel = new BuildingViewModel(); building_data_grid.ItemsSource = _buildingViewModel.LoadBuildingData(); add_btn_.IsEnabled = false; update_btn_.IsEnabled = false; delete_btn_.IsEnabled = false; buildingid_txtbx.Text = "Eg: 001"; }
/// <summary> /// Displays the Pallet or the Area view. Building mast be passed. If the building is not passed, then this is an error situation and the Building View is displayed. /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual ActionResult PalletOrArea(BuildingViewModel model) { if (!ModelState.IsValid) { // Building not passed. Ask for building. return(Building()); } if (!_service.ValidateBuilding(model.BuildingId)) { ModelState.AddModelError("", string.Format("Building {0} does not exist", model.BuildingId)); return(Building()); } // Interested in building specific areas only var areas = _service.GetCartonAreas(model.BuildingId).Where(p => p.BuildingId == model.BuildingId); // Counting only building specific areas switch (areas.Count()) { case 0: // No building specific area. So ask for area return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); case 1: // Ask for pallet var avm = PopulateAreaViewModel(model.BuildingId, areas.First().AreaId); return(Pallet(avm)); case 2: //Common case. One area which needs replenishment, and another area which provides replenishment. //In this case destination is the area which needs replenishment. try { var destArea = areas.Single(p => !string.IsNullOrEmpty(p.ReplenishAreaId)); //This code will never be executed. var palletModel = new PalletViewModel(destArea) { SuggestedLocations = _service.GetReplenishmentSuggestions(destArea.BuildingId, destArea.AreaId, destArea.ReplenishAreaId, 300, true) .Select(p => new ReplenishmentSuggestionModel(p)) }; return(View(Views.Pallet, palletModel)); } catch (InvalidOperationException) { // Perhaps both areas do not need replenishment. Ask for area. return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); } default: // Multiple areas. Ask for area. return(View(Views.Area, PopulateAreaViewModel(model.BuildingId, null))); } }
public ActionResult ViewBuildingUnits(int id) { var getBuildingunits = _buildingUnitsAppService.getAllBuildingUnits().ToList(); var buildingUnits = from Bu in getBuildingunits where Bu.BuildingId == id select Bu; var BuildingViewModel = new BuildingViewModel() { BuildingUnitsOutputs = buildingUnits }; return(View("_EditUnitModal", BuildingViewModel)); }
public void CreateNewBuilding(BuildingViewModel Building) { Db.Buildings.Add(new Building { Id = Building.Id, Phone = Building.Phone, Address = Building.Address, BuildingName = Building.BuildingName }); Db.SaveChanges(); }
public void ConfirmBuildingChange(int buildingId, string address) { var building = new BuildingViewModel(); building.id_budynku = buildingId; building.adres_budynku = address; var buildingModel = ViewModelMapper.Mapper.Map <BuildingModel>(building); residencesService.AddOrEditBuilding(buildingModel); }
public ActionResult ShowBuildingUnits(int buildingId) { var getBuildingunits = _buildingUnitsAppService.getAllBuildingUnits().ToList(); var buildingUnits = from Bu in getBuildingunits where Bu.BuildingId == buildingId select Bu; var BuildingViewModel = new BuildingViewModel() { BuildingUnitsOutputs = buildingUnits }; return(View("_CreatedBuildingUnitView", BuildingViewModel)); }
public BuildingController(ApplicationDbContext db, IMapper mapper) { _db = db; _mapper = mapper; BuildingVm = new BuildingViewModel() { Countries = _db.Countries.ToList(), Cities = _db.Cities.ToList(), Building = new Models.Building() }; }
public void PostChangesForEdit(BuildingViewModel editBuilding) { Db.Entry(new Building() { Id = editBuilding.Id, Phone = editBuilding.Phone, Address = editBuilding.Address, BuildingName = editBuilding.BuildingName }) .State = EntityState.Modified; Db.SaveChanges(); }
public BuildingViewModel BuildingById(int id) { var building = db.seat_building.Where(x => x.building_id == id).FirstOrDefault(); var _building = new BuildingViewModel() { building_id = building.building_id, building_name = building.building_name, no_of_rooms = building.no_of_rooms.HasValue ? building.no_of_rooms.Value : 0 }; return(_building); }
public int Update(BuildingViewModel repo, int buildingid) { var building = db.seat_building.Where(x => x.building_id == buildingid).FirstOrDefault(); if (building != null) { building.building_id = repo.building_id; building.building_name = repo.building_name; building.no_of_rooms = repo.no_of_rooms; } return(db.SaveChanges()); }
public int Insert(BuildingViewModel bvm) { seat_building building = new seat_building() { building_id = bvm.building_id, building_name = bvm.building_name, no_of_rooms = bvm.no_of_rooms }; db.seat_building.Add(building); return(db.SaveChanges()); }
private void Page_Loaded(object sender, RoutedEventArgs e) { _roomViewModel = new RoomViewModel(); _buildingViewModel = new BuildingViewModel(); room_data_grid.ItemsSource = _roomViewModel.LoadRoomData(); building_combobx.ItemsSource = _buildingViewModel.LoadBuildingData(); //roomtype_combobx.ItemsSource = _roomViewModel.LoadRoomData(); roomid_txtbx.Text = "Eg: 001001"; add_btn_.IsEnabled = false; update_btn_.IsEnabled = false; delete_btn_.IsEnabled = false; }
public ActionResult ShowUploadedFiles(int buildingId) { var uploadedFiles = _uploadFilesAppService.GetAllUploadedFiles(); var buildingUploadedFiles = from UF in uploadedFiles where UF.buildingId == buildingId orderby UF.Id descending select UF; var uploadedFilesViewModel = new BuildingViewModel() { UploadFilesOutputs = buildingUploadedFiles }; return(PartialView("_UploadedFilesView", uploadedFilesViewModel)); }
public virtual ActionResult Building() { //if (mobileView.HasValue) //{ // MobileEmulation.EmulateMobile(this.ControllerContext, mobileView.Value); // return RedirectToAction(Building()); //} var model = new BuildingViewModel(); model.AreaChoicesRequested += new EventHandler <EventArgs>(BuildingViewModel_AreaChoicesRequested); return(View(Views.Building, model)); }
public ActionResult Edit([Bind(Include = "Id,Phone,Address,BuildingName")] BuildingViewModel buildingViewModel) { if (Session["AccessLevel"] == null || int.Parse(Session["AccessLevel"].ToString()) == 1 || int.Parse(Session["AccessLevel"].ToString()) == 2 || int.Parse(Session["AccessLevel"].ToString()) == 3) { return(Redirect("~/NotAuthorized/Index")); } if (!ModelState.IsValid) { return(View(buildingViewModel)); } _services.PostChangesForEdit(buildingViewModel); return(RedirectToAction("Index")); }
public ActionResult Create() { var viewModel = new BuildingViewModel { Building = new Building { OrganisationId = UserOrganisationId }, Sites = new SelectList(HRBusinessService.RetrieveSites(UserOrganisationId), "SiteId", "Name") }; return(View(viewModel)); }
public ActionResult EditBuilding(int id) { var viewModel = new BuildingViewModel(); var building = _unitOfWork.BuildingRepository.Find(id); viewModel.ID = building.ID; viewModel.Name = building.BuildingDetails.Name; viewModel.Address = building.BuildingDetails.Address; viewModel.Email = building.BuildingDetails.Email; viewModel.ContactPhone = building.BuildingDetails.ContactPhone; viewModel.Description = building.BuildingDetails.Description; return(View(viewModel)); }
public ActionResult Edit([Bind(Include = "BuildingId,Address1,SiteId,Name")] Building building) { if (ModelState.IsValid) { HRBusinessService.UpdateBuilding(UserOrganisationId, building); return(RedirectToAction("Index")); } var viewModel = new BuildingViewModel { Sites = new SelectList(HRBusinessService.RetrieveSites(UserOrganisationId), "SiteId", "Name", building.SiteId), Building = building }; return(View(viewModel)); }
// GET: Admin/Building public ActionResult Index() { //ViewBag.DimentionAlert = Convert.ToInt32(TempData["dimensionAlert"]); //ViewBag.SpaceConflict = Convert.ToInt32(TempData["SpaceConflict"]); var buildingModel = new BuildingViewModel { Buildings = _context.Buildings.ToList(), Stories = _context.Stories.ToList(), Building = _context.Buildings.SingleOrDefault(b => b.Id == 1), Spaces = _context.Spaces.ToList() }; return(View(buildingModel)); }
public async Task <IActionResult> Create([Bind("Id,Name,BuildingType,FacilityId")] BuildingViewModel building) { Facility facility = _context.Facility.Find(building.FacilityId); if (ModelState.IsValid) { _context.Add(new Building { Name = building.Name, BuildingType = building.BuildingType, Facility = facility }); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(building)); }