private static JobEmployeeResponse ConvertJobEmployeeToJobEmployeeResponse(JobEmployee jobEmployee) { return(new JobEmployeeResponse(jobEmployee.Id, jobEmployee.Job.Name, jobEmployee.Start, jobEmployee.End, jobEmployee.MonthlySalaryGross, jobEmployee.YearlySalaryGross)); }
public void SaveJobEmployee(JobEmployee je) { if (je.JobEmployeeID > 0) { //==== UPDATE ==== DB.JobEmployees.Attach(je); DB.Entry(je).State = EntityState.Modified; } else { //==== INSERT ==== DB.JobEmployees.Add(je); } DB.SaveChanges(); }
protected void AddToSub_Click(object sender, EventArgs e) { if (SubGroups.SelectedIndex != -1) { bool isadd = false; string text = SubGroups.SelectedItem.Text; string value = SubGroups.SelectedItem.Value; for (int i = 0; i < SelectedSubGroups.Items.Count; i++) { if (SelectedSubGroups.Items[i].Text == text) { isadd = true; } } if (!isadd) { SelectedSubGroups.Items.Add(new ListItem(text, value)); JobEmployee je = new JobEmployee(); je.EmployeeID = empid; je.JobID = value.ToInt(); EmployeeJobRepository ejr = new EmployeeJobRepository(); ejr.SaveJobEmployee(je); NoItemDiv.InnerText = ""; } else { NoItemDiv.InnerText = "این مورد قبلا اضافه شده است!"; NoItemDiv.Attributes["class"] = "error"; } } else { NoItemDiv.InnerText = "شما هیچ موردی را انتخاب نکرده اید!"; NoItemDiv.Attributes["class"] = "error"; } }
public async Task UpdateAsync(JobEmployee jobEmployee) { _dbContext.Entry(jobEmployee).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); }
public async Task RemoveAsync(JobEmployee jobEmployee) { _dbContext.JobEmployees.Remove(jobEmployee); await _dbContext.SaveChangesAsync(); }
public async Task AddAsync(JobEmployee jobEmployee) { _dbContext.JobEmployees.Add(jobEmployee); await _dbContext.SaveChangesAsync(); }