public ActionResult Details(int?id) { if (System.Web.HttpContext.Current.Session["CurrentUser"] is ConnectedWorker) { if ((System.Web.HttpContext.Current.Session["CurrentUser"] as ConnectedWorker).Power == 2 || (System.Web.HttpContext.Current.Session["CurrentUser"] as ConnectedWorker).Power == 0) { if (id == null) { return(HttpNotFound()); } WorkPlace workPlace = db.WorkPlaces.Find(id); if (workPlace != null) { return(View(workPlace)); } return(HttpNotFound()); } else { return(HttpNotFound()); } } else { return(HttpNotFound()); } }
public ActionResult DeleteConfirmed(int id) { if (System.Web.HttpContext.Current.Session["CurrentUser"] is ConnectedWorker) { if ((System.Web.HttpContext.Current.Session["CurrentUser"] as ConnectedWorker).Power == 2) { try { WorkPlace workPlace = db.WorkPlaces.Find(id); if (workPlace == null) { return(HttpNotFound()); } db.WorkPlaces.Remove(workPlace); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } else { return(HttpNotFound()); } } else { return(HttpNotFound()); } }
public async Task <ActionResult> AddNewWorkPlace(WorkPlaceModel workPlace) { if (ModelState.IsValid) { var empId = HttpContext.Session.GetObjectFromJson <Employee>("Employ").Id; var empWorkPlace = await dbContext.Placeswork.Where(x => x.EmployeeId == empId).ToListAsync(); if (empWorkPlace.Count == 0) { var companyId = options.Value.CompanyId; var positionsId = options.Value.PositionsId; var emporiumId = options.Value.EmporiumId; var salaryId = options.Value.SalaryId; WorkPlace place = new WorkPlace { EmployeeId = empId, EmporiumId = (int)emporiumId, PositionsId = (int)positionsId, StarDate = workPlace.StartDate }; await dbContext.Placeswork.AddAsync(place); await dbContext.SaveChangesAsync(); ModelState.AddModelError("", "Success"); } else { ModelState.AddModelError("", "You have already added a job "); } } return(View()); }
public ActionResult Edit(WorkPlace workPlace) { if (System.Web.HttpContext.Current.Session["CurrentUser"] is ConnectedWorker) { if ((System.Web.HttpContext.Current.Session["CurrentUser"] as ConnectedWorker).Power == 2) { try { db.Entry(workPlace).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } else { return(HttpNotFound()); } } else { return(HttpNotFound()); } }
void Build() { MeshCollider meshCollider = GetComponent <MeshCollider>(); Homes home = GetComponent <Homes>(); WorkPlace workPlace = GetComponent <WorkPlace>(); rend.material = finishedMaterial; GameController.Instance.displayText.text = ""; if (meshCollider) { meshCollider.isTrigger = false; meshCollider.convex = false; } if (home) { home.enabled = true; } if (workPlace) { workPlace.enabled = true; } gameObject.layer = 0; Destroy(this); }
public async Task<ActionResult<WorkPlace>> PostWorkPlace(WorkPlace workPlace) { _context.workPlaces.Add(workPlace); await _context.SaveChangesAsync(); return CreatedAtAction("GetWorkPlace", new { id = workPlace.WPId }, workPlace); }
public async Task <IActionResult> Add(int empId) { var departments = await _dbContext.Departments.ToListAsync(); var holdings = await _dbContext.Holdings.ToListAsync(); var employee = await _dbContext.Employees.Where(wp => wp.Id == empId).FirstOrDefaultAsync(); var branches = await _dbContext.Branches.ToListAsync(); WorkPlace workPlace = await _dbContext.WorkPlaces .Where(wp => wp.EmployeeId == empId) .Include(wp => wp.Position) .ThenInclude(p => p.Department) .Include(wp => wp.Branch) .ThenInclude(b => b.Company) .ThenInclude(c => c.Holding) .FirstOrDefaultAsync(); WorkPlaceModel model = new WorkPlaceModel { Departments = departments, Employee = employee, Holdings = holdings, Branches = branches }; return(View(model)); }
public ActionResult DeleteConfirmed(int id) { WorkPlace workPlace = _workPlaceService.GetById(id); _workPlaceService.Delete(workPlace); return(RedirectToAction("Index")); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.layer == 11 || other.gameObject.layer == 10) { if (other.gameObject.layer == 10) { myMesh.mesh = other.GetComponentInParent <WorkPlace>().changemesh; myMaterial.material = other.GetComponentInParent <WorkPlace>().ChangeMaterial; } if (1 < other.gameObject.layer == 1 < workZoneLayer) { TriggerWorkAnimation(other); transform.position = new Vector3(other.transform.position.x, transform.position.y, other.transform.position.z); m_currentWorkPlace = other.GetComponentInParent <WorkPlace>(); if (m_currentWorkPlace.finalWorkSpeed < 1) { quality -= quality * .15f; } else if (m_currentWorkPlace.finalWorkSpeed > 1) { quality += quality * .15f; } if (quality > 100) { quality = 100; } StartCoroutine(WaitRoutine()); return; } } }
private void OnTriggerExit(Collider other) { workZoneCounter++; m_currentWorkPlace = null; stuck = false; }
public ActionResult Create([Bind(Include = "Id,PlaceId,BuildingId")] WorkPlace workPlace) { if (System.Web.HttpContext.Current.Session["CurrentUser"] is ConnectedWorker) { if ((System.Web.HttpContext.Current.Session["CurrentUser"] as ConnectedWorker).Power == 2) { try { db.WorkPlaces.Add(workPlace); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } else { return(HttpNotFound()); } } else { return(HttpNotFound()); } }
void GenerateImmigrationCase(CitizenClass _class) { //for each citizen class: //generate citizen. //assign home. //assign work. Citizen newCitizen = GenerateCitizen(_class); ResidentialBuilding home = GameManager.buildingsMan.GetResidentialBuildingWithEmptySlot(_class); if (home != null) //this shouldn't fail. { newCitizen.homeAddress = home; home.AddResident(newCitizen); } else { print("ERROR! Could not assign home to a citizen"); } WorkPlace workPlace = GameManager.buildingsMan.GetEmptyWorkSlot(newCitizen.educationalLevel); if (workPlace != null) //contrary to the home case, this is a possibility. { newCitizen.workAddress = workPlace; workPlace.AssignEmployee(newCitizen); } population.Add(newCitizen); }
public static WorkPlaceModel ToModel(this WorkPlace entity) { if (entity == null) { throw new NullReferenceException("WorkPlace is null"); } var model = new WorkPlaceModel() { Id = entity.Id, City = entity.City, Name = entity.Name, Description = entity.Description, Position = entity.Position, From = entity.From, To = entity.To, ResumeId = entity.ResumeId }; foreach (var duty in entity.Duties) { model.Duties.Add(duty.ToModel()); } foreach (var project in entity.Projects) { model.Projects.Add(project.ToModel()); } return(model); }
public static WorkPlace ToEntity(this WorkPlaceModel model) { // создаем новую работу var entity = new WorkPlace() { Id = model.Id.HasValue ? model.Id.Value : 0, City = model.City, Name = model.Name, Description = model.Description, Position = model.Position, From = model.From, To = model.To, ResumeId = model.ResumeId.HasValue ? model.ResumeId.Value : 0 }; // добавляем в нее обязанности foreach (var duty in model.Duties) { entity.Duties.Add(duty.ToEntity()); } // добавляем в нее проекты foreach (var project in model.Projects) { entity.Projects.Add(project.ToEntity()); } return(entity); }
public async Task<IActionResult> PutWorkPlace(int id, WorkPlace workPlace) { if (id != workPlace.WPId) { return BadRequest(); } _context.Entry(workPlace).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkPlaceExists(id)) { return NotFound(); } else { throw; } } return NoContent(); }
public Person(string name, int salary, bool isHead, WorkPlace work) { Name = name; Salary = salary; IsHead = isHead; Work = work; }
public Citizen() { //isInDebt = false; spouse = null; workAddress = null; health = 100; }
public IHttpActionResult CreateWorkPlace(WorkPlaceDto workPlaceDto) { if (!ModelState.IsValid) { return(BadRequest()); } var workPlace = new WorkPlace() { Id = workPlaceDto.Id, Name = workPlaceDto.Name, WorkPlaceTypeId = workPlaceDto.WorkPlaceTypeDtoId, Tel = workPlaceDto.Tel, Address = workPlaceDto.Address, FieldOfActivity = workPlaceDto.FieldOfActivity, Created = DateTime.Now }; _context.WorkPlaces.Add(workPlace); _context.SaveChanges(); workPlaceDto.Id = workPlace.Id; return(Created(new Uri(Request.RequestUri + "/" + workPlace.Id), workPlaceDto)); }
public ActionResult <WorkPlace_Position_Branch_Model> Get_EditWorkPlace(int?id) { if (id.HasValue) { var sa = new JsonSerializerSettings(); WorkPlace workPlace = context.WorkPlaces.Where(x => x.Id == id).Include(x => x.Position).Include(x => x.Branch).First(); var department = context.Departments.Where(x => x.Id == workPlace.Position.DepartmentId).FirstOrDefault(); WorkPlace_Position_Branch_Model workPlace_Position_Branch_Model = new WorkPlace_Position_Branch_Model { BranchName = workPlace.Branch.Name, Entry = workPlace.EntryDate, PositionName = workPlace.Position.Namme, DepartmentName = department.Name, WorkPlaceId = workPlace.Id, EmployeeId = workPlace.EmployeeId }; return(Json(workPlace_Position_Branch_Model, sa)); } return(View()); }
public async Task <GenericResponse> Handle(Command request, CancellationToken cancellationToken) { if (await _context.Workplaces.AnyAsync(x => x.Label == request.Label && x.Location == request.Location)) { return new GenericResponse { Errors = new[] { $"Work place labeled {request.Label} already exists at {request.Location}" } } } ; var workPlace = new WorkPlace { Label = request.Label, Location = request.Location }; if (request.WorkPlaceLeaderID != default) { var workPlaceLeader = await _context.WorkPlaceLeaders.Include(x => x.WorkPlace).ThenInclude(x => x.WorkPlaceLeader).SingleOrDefaultAsync(x => x.ID == request.WorkPlaceLeaderID); if (workPlaceLeader == null) { return new GenericResponse { Errors = new[] { "Work place leader not found" } } } ; var leaderEmployee = await _context.Employees.Include(x => x.WorkPlace).ThenInclude(x => x.Employees).SingleOrDefaultAsync(x => x.ID == workPlaceLeader.ID); if (leaderEmployee.WorkPlace != null) { leaderEmployee.WorkPlace.Employees.Remove(leaderEmployee); } if (workPlaceLeader.WorkPlace != null) { workPlaceLeader.WorkPlace.WorkPlaceLeader = null; } workPlace.WorkPlaceLeader = workPlaceLeader; workPlace.WorkPlaceLeaderID = request.WorkPlaceLeaderID; workPlace.Employees = new System.Collections.Generic.List <Employee>() { leaderEmployee }; } await _context.Workplaces.AddAsync(workPlace); await _context.SaveChangesAsync(); return(new GenericResponse { Success = true }); } }
//保存内容 private void btnEdit_SaveClickHandleClick(object sender, EventArgs e) { // 这里是插入方法 if (EditOrInsert == 0) { //判断为空 if (string.IsNullOrEmpty(dgvBaseList.Rows[index].Cells["dgvBaseListName"].Value.ToString())) { lblError.Text = "名称没有添入内容"; return; //存在相同直接返回 } //这是插入记录 行号为Index for (int i = 0; i < dgvBaseList.Rows.Count - 1; i++) { if (dgvBaseList.Rows[i].Cells["dgvBaseListName"].Value.ToString().Trim() == dgvBaseList.Rows[index].Cells["dgvBaseListName"].Value.ToString()) { dgvBaseList.Rows[i].Cells["dgvBaseListName"].Style.BackColor = Color.Red; lblError.Text = "存在相同项"; return; //存在相同直接返回 } } //这里插入记录 WorkPlace bs = new WorkPlace(); bs.Name = dgvBaseList.Rows[index].Cells["dgvBaseListName"].Value.ToString(); bs.Code = dgvBaseList.Rows[index].Cells["dgvBaseListCode"].Value.ToString(); new BaseManager <WorkPlace>().InsertBoxSize(bs); } //这里是修改记录方法 if (EditOrInsert == 1) { //进行相同比较 for (int i = 0; i < dgvBaseList.Rows.Count - 1; i++) { for (int j = i + 1; j < dgvBaseList.Rows.Count; j++) { if (dgvBaseList.Rows[i].Cells["dgvBaseListName"].Value.ToString() == dgvBaseList.Rows[j].Cells["dgvBaseListName"].Value.ToString()) { //存在相同 红色显示 dgvBaseList.Rows[i].Cells["dgvBaseListName"].Style.BackColor = Color.Red; dgvBaseList.Rows[j].Cells["dgvBaseListName"].Style.BackColor = Color.Red; lblError.Text = "存在相同的内容"; return; } } } foreach (DataGridViewRow item in dgvBaseList.Rows) //循环更新 { WorkPlace bs = new WorkPlace(); bs.ID = item.Cells["dgvBaseListID"].Value.ToString(); bs.Name = item.Cells["dgvBaseListName"].Value.ToString(); bs.Code = item.Cells["dgvBaseListCode"].Value.ToString(); new BaseManager <WorkPlace>().UpdateBoxSize(bs); } } btnEdit.isTrue = true; lblError.Text = ""; Init(); }
public ActionResult DeleteConfirmed(int id) { WorkPlace workplace = db.WorkPlaces.Find(id); db.WorkPlaces.Remove(workplace); db.SaveChanges(); return(RedirectToAction("Index")); }
public WorkPlace Post(WorkPlace oppRequest) { if (oppRequest == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } return(workplaceService.SaveWorkPlace(oppRequest.CreateFrom()).CreateFrom()); }
public Boolean Delete(WorkPlace workPlace) { if (workPlace == null || !ModelState.IsValid) { throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request"); } workplaceService.DeleteWorkPlace(workPlace.WorkPlaceId); return(true); }
public ActionResult Edit([Bind(Include = "wp_id,wp_name")] WorkPlace workPlace) { if (ModelState.IsValid) { db.Entry(workPlace).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(workPlace)); }
protected override void Awake() { base.Awake(); workPlace = this.gameObject.GetComponent <WorkPlace>(); smoke = this.transform.Find("Smoke").GetComponent <ParticleSystem>(); UpdateEmissionVisuals(0.0f); stats.type = BuildingType.industrial; currentProduction = 0; }
public ActionResult Edit([Bind(Include = "Id,CompanyName,StartDate,EndDate,UserId")] WorkPlace workPlace) { if (ModelState.IsValid) { _workPlaceService.Update(workPlace); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(_userService.GetAll(), "Id", "Name", workPlace.UserId); return(View(workPlace)); }
protected void SetWorkplaceDetails(Building building) //to be called only for buildings with workplaces. { BuildWorkplaceFieldsReferences(); WorkPlace workPlace = building.gameObject.GetComponent <WorkPlace>(); employeeCount.text = workPlace.CurrentManpower().ToString(); employeeCapacity.text = workPlace.MaxManpower().ToString(); employeeEducationLevel.text = GetEducationLevelString(workPlace.WorkerEducationLevel()); wages.text = workPlace.Wages().ToString(); workplaceQuality.text = workPlace.WorkplaceQuality().ToString(); }
public async Task <IActionResult> Create([Bind("Id,Name")] WorkPlace workPlace) { if (ModelState.IsValid) { _context.Add(workPlace); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(workPlace)); }
public ActionResult Edit([Bind(Include = "Id,DivisionId,Name,Description")] WorkPlace workplace) { if (ModelState.IsValid) { db.Entry(workplace).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DivisionId = new SelectList(db.Divisions, "Id", "Name", workplace.DivisionId); return(View(workplace)); }