/// <summary> /// Adds an employee to the database and returns an Enum with success or fail /// </summary> /// <param name="emp"></param> /// <returns></returns> public ResultsEnum Add(Employee emp) { try { EmpDao.AddEmployee(emp); return(ResultsEnum.Success); } catch (Exception e) { Console.WriteLine("Error from EmployeeDAO/AddEmployee" + e.Message); return(ResultsEnum.Fail); } }
public IActionResult Create([FromBody] Employee employee) { if (employee == null) { return(BadRequest()); } try{ objemployee.AddEmployee(employee); //var outputModel = ToOutputModel(model); //return CreatedAtRoute("GetMovie", // new { id = outputModel.Id }, outputModel); return(Ok()); } catch (Exception e) { return(BadRequest()); } }
private void btnAdd_Click(object sender, EventArgs e) { EmployeeDao emDao = new EmployeeDao(); if (txtName.Text.Length > 0 && txtAddress.Text.Length > 0 && txtPhoneNumber.Text.Length > 0 && txtPosition.Text.Length > 0) { try { emDao.AddEmployee(new Employee(txtName.Text, cboGender.SelectedIndex == 0, txtPosition.Text, txtAddress.Text, txtPhoneNumber.Text)); }catch (Exception ex) { MessageBox.Show("Failed : " + ex.Message); } LoadTable(); txtName.Text = ""; txtAddress.Text = ""; txtPhoneNumber.Text = ""; txtPosition.Text = ""; txtStartDate.Text = ""; } }
public IHttpActionResult AddEmployee(Employee employee) { if (employee == null) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("No data present in the header")), ReasonPhrase = "Not Found Data in the Header" }; throw new HttpResponseException(resp); } if (dao.AddEmployee(employee)) { log.Info("Employee Added Successfully"); return(Ok(employee)); } else { log.Error("Employe Not Added successfully"); return(NotFound()); } }