static void AddEmployee() { try { Employee employee = new Employee(); Console.WriteLine("Enter ID: "); employee.ID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Name: "); employee.Name = Console.ReadLine(); Console.WriteLine("Enter Contact: "); employee.Contact = Convert.ToInt64(Console.ReadLine()); Console.WriteLine("Enter city: "); employee.City = Console.ReadLine(); Console.WriteLine("Enter Department"); employee.Department = Console.ReadLine(); EmployeeBLL empBLL = new EmployeeBLL(); if (empBLL.AddEmployeeBLL(employee)) { Console.WriteLine("Employee Added Successfully"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
// POST: api/Employee public HttpResponseMessage Post([FromBody] EmployeeBO emp) //Ok { try { bll.AddEmployeeBLL(emp); var message = Request.CreateResponse(HttpStatusCode.Created, emp); message.Headers.Location = new Uri(Request.RequestUri + "/" + emp.Id.ToString()); return(message); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public void AddEmployeeDetails() { EmployeeBO employee = new EmployeeBO(); EmployeeBLL bll = new EmployeeBLL(); Console.Write("Pls, enter Employee First Name: "); employee.FirstName = Console.ReadLine(); Console.Write("Pls enter Employee Last Name: "); employee.LastName = Console.ReadLine(); Console.Write("Pls enter Company name: "); employee.CompanyName = Console.ReadLine(); if (!String.IsNullOrWhiteSpace(employee.FirstName) && !String.IsNullOrWhiteSpace(employee.LastName) && !String.IsNullOrWhiteSpace(employee.CompanyName)) { bll.AddEmployeeBLL(employee); } else { Console.WriteLine("All fields required / empty strings or white spaces are not allowed"); } }