public void AddEmployees() { string joinYear = dateJoin.Value.Year.ToString(); string joinMonth = dateJoin.Value.Month.ToString("D2"); string joinDay = dateJoin.Value.Day.ToString("D2"); string birthYear = dateBirth.Value.Year.ToString(); string birthMonth = dateBirth.Value.Month.ToString("D2"); string birthDay = dateBirth.Value.Day.ToString("D2"); employee.EmployeeName = txtName.Text; employee.Address = txtAddress.Text; employee.Phone = txtPhone.Text; employee.Gender = comboGender.Text; employee.Education = txtEducation.Text; employee.Post = comboPost.Text; employee.Salary = Convert.ToInt32(txtSalary.Text); employee.BloodGroup = comboBloodGroup.Text; employee.Joindate = joinDay + "-" + joinMonth + "-" + joinYear; employee.Birthdate = birthDay + "-" + birthMonth + "-" + birthYear; employee.Password = txtPassword.Text; if (employeeServices.Add(employee) == 1) { MessageBox.Show("Record Added Successfully!"); employeeDataGridView.DataSource = employeeServices.GetAll(); } else { MessageBox.Show("Could not store data!!"); } }
public IActionResult Add(EmployeeAddModel employeeAddModel) { if (!ModelState.IsValid) //VALİDASYON UYMUYORSA EKRANA GERİ DÖN. { return(View(employeeAddModel)); } else //UYUYORSA, GELEN BİLGİLERLE NESNE OLUŞTUR VE DATAACCESS'E YOLLA. { Employee employee = new Employee { FirstName = employeeAddModel.Name, LastName = employeeAddModel.Lastname, City = employeeAddModel.City, Country = employeeAddModel.Country, Adress = employeeAddModel.Adress, HomePhone = employeeAddModel.Phone }; IEmployeeServices.Add(employee); return(RedirectToAction("Index")); } }
public async Task <ActionResult <Employee> > PostEmployee(Employee employee) { await services.Add(employee); return(CreatedAtAction("GetEmployee", new { id = employee.id }, employee)); }