public void Save(JobRole jobRole) { if (jobRole.Id == 0) _dataContext.JobRoles.Add(jobRole); _dataContext.SaveChanges(); }
public async Task <IActionResult> Edit(int id, [Bind("JobRoleCode,Job")] JobRole jobRole) { if (id != jobRole.JobRoleCode) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(jobRole); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JobRoleExists(jobRole.JobRoleCode)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(jobRole)); }
public IActionResult Create() { JobRole model = new JobRole(); model.JobId = 0; ViewBag.Departments = _Department.GetDepartments; return View(model); }
public async Task <IActionResult> Edit(int id, [Bind("Id,OrgId,Title,Description")] JobRole jobRole) { if (id != jobRole.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(jobRole); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JobRoleExists(jobRole.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OrgId"] = new SelectList(_context.Organization, "Id", "Name", jobRole.OrgId); return(View(jobRole)); }
public async Task <ActionResult <JobRole> > PostRole(JobRole role) { _context.JobRoles.Add(role); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRole", new { id = role.Id }, role)); }
internal void AddJobRole(JobRole jobRole) { lock (_jobRolesSyncLock) { _organisation.JobRoles.Add(jobRole); } }
public void Remove(int?Id) { JobRole dbEntity = db.JobRole.Find(Id); db.JobRole.Remove(dbEntity); db.SaveChanges(); }
public IActionResult DetailsView(JobActivityViewModel vm) { if (ModelState.IsValid) { Activitity act = new Activitity { Name = vm.Name, Date = vm.Date, Description = vm.Description, RemarkId = vm.RemarkId, Remark = remark.GetRemark(vm.RemarkId), JobRole = vm.Job }; JobRole role = serve.GetJobByActivity(vm); if (role == null) { return(NotFound()); } vm.Job = role; act.JobRole = role; activitity.Create(act); vm = GetJobActivityViewModel(role); vm.JobId = role.Id; //return RedirectToAction("Index"); return(View(vm)); } return(View(vm)); }
/// <summary> /// Delete User Action Activity Log /// </summary> /// <param name=></param> /// <returns>bool</returns> public async Task <bool> DeleteJobRole(int JobRoleId) { #region Declare a return type with initial value. bool isJobRoleDeleted = default(bool); #endregion try { if (JobRoleId > default(int)) { #region Vars JobRole JobRole = null; #endregion #region Get JobRole by id JobRole = await UnitOfWork.JobRoleRepository.GetById(JobRoleId); #endregion #region check if object is not null if (JobRole != null) { JobRole.IsDeleted = (byte)DeleteStatusEnum.Deleted; #region Apply the changes to the database UnitOfWork.JobRoleRepository.Update(JobRole); isJobRoleDeleted = await UnitOfWork.Commit() > default(int); #endregion } #endregion } } catch (Exception exception) { } return(isJobRoleDeleted); }
private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); int id = GetQueryIntValue("id"); if (id > 0) { JobRole current = DB.JobRoles.Find(id); if (current == null) { // 参数错误,首先弹出Alert对话框然后关闭弹出窗口 Alert.Show("参数错误!", String.Empty, ActiveWindow.GetHideReference()); return; } tbxName.Text = current.Name; tbxRemark.Text = current.Remark; if (current.Level.HasValue) { tbxLevel.Text = current.Level.ToString(); } tbxDisplayOrder.Text = current.DisplayOrder.ToString(); cbxEnabled.Checked = current.IsActive; } }
protected void btnSaveClose_Click(object sender, EventArgs e) { int id = GetQueryIntValue("id"); JobRole jobrole = null; if (id > 0) { jobrole = DB.JobRoles.Find(id); } else { jobrole = new JobRole(); } jobrole.Name = tbxName.Text.Trim(); jobrole.Remark = tbxRemark.Text.Trim(); if (!string.IsNullOrEmpty(tbxLevel.Text)) { jobrole.Level = Change.ToInt(tbxLevel.Text); } jobrole.DisplayOrder = Change.ToInt(tbxDisplayOrder.Text); jobrole.IsActive = cbxEnabled.Checked; if (id == 0) { DB.JobRoles.Add(jobrole); } SaveChanges(); //FineUIPro.Alert.Show("保存成功!", String.Empty, FineUIPro.Alert.DefaultIcon, FineUIPro.ActiveWindow.GetHidePostBackReference()); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }
private void BtnSalvar_Click(object sender, EventArgs e) { try { ValidateData(); } catch (Exception) { return; } JobRole jobRole = new JobRole() { Name = txtCargo.Text, Level = txtNivel.Text }; if (idToUpdate != null) { jobRole.Id = Convert.ToInt64(idToUpdate); } if (jobRole.Id == 0) { _service.Create(jobRole); } else { _service.Update(jobRole); } MessageBox.Show("Cargo salvo com sucesso", "Cargos", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Close(); }
public async Task <IActionResult> PutJobRole(byte id, JobRole jobRole) { if (id != jobRole.JobRoleId) { return(BadRequest()); } _context.Entry(jobRole).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JobRoleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private Int32 SubmitJobRole(JobRole data) { var parameterList = new List <System.Data.IDbDataParameter> { new SqlParameter() { ParameterName = "@JobRoleId", Value = data.Id, SqlDbType = SqlDbType.Int }, new SqlParameter() { ParameterName = "@SkillCouncilId", Value = data.SkillCouncilId, SqlDbType = SqlDbType.Int }, new SqlParameter() { ParameterName = "@Code", Value = data.Code, SqlDbType = SqlDbType.VarChar, Size = 10 }, new SqlParameter() { ParameterName = "@Name", Value = data.Name, SqlDbType = SqlDbType.VarChar, Size = 500 }, new SqlParameter() { ParameterName = "@Description", Value = data.Description, SqlDbType = SqlDbType.VarChar, Size = 500 }, new SqlParameter() { ParameterName = "@CreatedBy", Value = data.CreatedBy, SqlDbType = SqlDbType.Int }, new SqlParameter() { ParameterName = "@ModifiedBy", Value = data.ModifiedBy, SqlDbType = SqlDbType.Int }, new SqlParameter() { ParameterName = "@IsActive", Value = data.IsActive, SqlDbType = SqlDbType.Bit }, new SqlParameter() { ParameterName = "JobRoleId", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.ReturnValue } }; //Comment : Here get DbConnector object var rowEffeted = GetDbConnector().ExecuteNonQuery("MaintainJobRoles", QueryCommandType.StoredProcedure, parameterList); //if successfully executed if (rowEffeted > 0) { Int32 jobRoleId = Convert.ToInt32(parameterList[parameterList.Count() - 1].Value); return(jobRoleId); } else { //LoggingService.Instance.Fatal(string.Format("Unable to add user :{0}{1}", Environment.NewLine, object)); } return(0); }
public IHttpActionResult Put(JobRole jobRole, int skillCouncilId, int jobRoleId) { OperationStatus operationStatus = new OperationStatus() { ServiceMethod = "PUT", ServiceName = "UpdateJobRole", RequestProcessed = false, RequestSuccessful = false }; if (jobRole != null) { if (jobRoleId > 0 && skillCouncilId > 0) { //Comment : Here set value of skillCouncilId & jobRoleId into DTO object and then call Update method jobRole.Id = jobRoleId; jobRole.SkillCouncilId = skillCouncilId; operationStatus = GetJobRolesDbService().UpdateJobRoles(jobRole); } else { operationStatus.Messages.Add(new Message() { DTOName = "JobRole", DTOProperty = "", MessageType = MessageType.SystemError, Text = "Please use POST method to create object." }); } } return(Ok(operationStatus)); }
public JobRole Create(JobRole jobRole) { Context.JobRoles.Add(jobRole); Context.SaveChanges(); return(jobRole); }
private JobActivityViewModel GetJobActivityViewModel(JobRole job) { JobActivityViewModel viewModel = new JobActivityViewModel(); viewModel.Job = job; viewModel.Activitities = activitity.GetActivitiesByJob(job); return(viewModel); }
public ActionResult DeleteConfirmed(string id) { JobRole jobRole = db.JobRole.Find(id); db.JobRole.Remove(jobRole); db.SaveChanges(); return(RedirectToAction("Index")); }
public JobRole GetJobRole(int?Id) { JobRole dbEntity = db.JobRole.Find(Id); //JobRole dbEntity = db.JobRole.Include(d => d.Departments) // .SingleOrDefault(j => j.JobId); return(dbEntity); }
public void Update(int?id, JobRole job) { var entity = context.Set <JobRole>().Find(id); entity.Position = job.Position; context.Set <JobRole>().Update(entity); context.SaveChanges(); }
public Employee(int id, string firstname, string lastname, string password, JobRole role, string username) { EmployeeId = id; Firstname = firstname; Lastname = lastname; Password = password; Role = role; Username = username; }
public void Save(JobRole jobRole) { if (jobRole.Id == 0) { _dataContext.JobRoles.Add(jobRole); } _dataContext.SaveChanges(); }
public IActionResult Create(JobRole model) { if (ModelState.IsValid) { _JobRole.Add(model); return RedirectToAction("Index"); } return View(model); }
protected void btnSave_Click(object sender, EventArgs e) { ReviewRepository reviewRepository = new ReviewRepository(); JobRole role = new JobRole(); role.Role = txtRole.Text; reviewRepository.InsertRole(role); Response.Redirect(Request.RawUrl); }
public void T0300HrmJobRoleRelation() { // get system user var u = User.FindOne(x => x.Name == "SYSTEM"); Assert.IsNotNull(u); // get organisational unit var ou = OrganisationalUnit.FindOne(x => x.Id == 1); Assert.IsNotNull(ou); // get employee var emp = Employee.FindOne(x => x.Id == 1); Assert.IsNotNull(emp); // create employee job role relation var rel1 = new EmployeeRoleRelation { CreatedBy = u.Id, Active = true, Start = DateTime.Now, }; rel1.Employee.Value = emp; rel1.Save(); // create job role relation var rel = new JobRoleRelation { CreatedBy = u.Id, Active = true, Type = JobRoleRelationType.Manager, }; rel.OrganisationalUnit.Value = ou; rel.Save(); var jr = new JobRole { CreatedBy = u.Id, Code = "CEO", Name = "CEO", Description = "CEO" }; jr.JobRoleRelations.Add(rel); jr.EmployeeRoleRelations.Add(rel1); jr.Save(); // get organisational unit ou = OrganisationalUnit.FindOne(x => x.Id == 1); Assert.IsNotNull(ou); Assert.AreEqual(1, ou.JobRoleRelations.Count); Assert.AreEqual("CEO", ou.JobRoleRelations[0].JobRole.Value.Code); Assert.AreEqual(1, ou.JobRoleRelations[0].JobRole.Value.EmployeeRoleRelations.Count); Assert.AreEqual("Mustermann", ou.JobRoleRelations[0].JobRole.Value.EmployeeRoleRelations[0].Employee.Value.Person.Value.LastName); // error }
public ActionResult Edit([Bind(Include = "id,RegisteredCompanyid,JobTitle,JobRoleid")] JobRole jobRole) { if (ModelState.IsValid) { db.Entry(jobRole).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobRole)); }
public ActionResult Create([Bind(Include = "id,RegisteredCompanyid,JobTitle,JobRoleid")] JobRole jobRole) { if (ModelState.IsValid) { db.JobRole.Add(jobRole); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobRole)); }
internal void RemoveJobRole(JobRole jobRole) { lock (_jobRolesSyncLock) { var existingJobRole = _organisation.JobRoles.Find(x => x.EntityKey == jobRole.EntityKey); if (existingJobRole != null) { _organisation.JobRoles.Remove(existingJobRole); } } }
public JobRole Update(JobRole jobRole) { var jobRoleToUpdate = Context.JobRoles.First(jb => jb.Id == jobRole.Id); jobRoleToUpdate.Name = jobRole.Name; jobRoleToUpdate.Level = jobRole.Level; Context.Entry(jobRoleToUpdate).State = EntityState.Modified; Context.SaveChanges(); return(jobRoleToUpdate); }
public async Task <IActionResult> Create([Bind("JobRoleCode,Job")] JobRole jobRole) { if (ModelState.IsValid) { _context.Add(jobRole); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(jobRole)); }
public async Task <IActionResult> Create([Bind("Id,OrgId,Title,Description")] JobRole jobRole) { if (ModelState.IsValid) { _context.Add(jobRole); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OrgId"] = new SelectList(_context.Organization, "Id", "Name", jobRole.OrgId); return(View(jobRole)); }
public void AddToJobRoles(JobRole jobRole) { base.AddObject("JobRoles", jobRole); }
public void Delete(JobRole jobRole) { _dataContext.JobRoles.Remove(jobRole); _dataContext.SaveChanges(); }
public static JobRole CreateJobRole(int ID, string jobRoleDescription, byte[] rowVersion) { JobRole jobRole = new JobRole(); jobRole.Id = ID; jobRole.JobRoleDescription = jobRoleDescription; jobRole.RowVersion = rowVersion; return jobRole; }