示例#1
0
 // GET api/employee
 /// <summary>
 /// This method uses the Manage Employee service to retrieve all employees from the database
 /// </summary>
 /// <returns>
 /// Employees data with 200 status on Success,
 /// Exception with 500 status on Failure
 /// </returns>
 public IHttpActionResult Get()
 {
     try {
         return(Ok(ManageEmployee.getAllEmployees()));
     }
     catch (Exception e)
     {
         return(BadRequest(e.ToString()));
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            ManageEmployee manage = new ManageEmployee();

            Console.OutputEncoding = System.Text.Encoding.Unicode;
            Console.InputEncoding  = System.Text.Encoding.Unicode;
            manage.update();
            Console.Clear();
            manage.display();
        }
示例#3
0
        //// PUT api/employee/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}

        // DELETE api/employee/5
        /// <summary>
        /// This method uses the Manage Employee service to delete an employee from the database with
        /// the Employee Id received in the DELETE request.
        /// </summary>
        /// <param name="id">
        /// Employee Id extracted from the URL of the incoming DELETE request
        /// </param>
        /// <returns>
        /// 200 status on Success
        /// Exception with 500 status on Failure
        /// </returns>
        public IHttpActionResult Delete(int id)
        {
            try
            {
                ManageEmployee.deleteEmployee(id);
                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.ToString()));
            }
        }
        public async Task <bool> registerEmployee([FromBody] ManageEmployee manageEmployee)
        {
            var manageEmployeeData = await context.retrieveByEmail(manageEmployee.employeeEmail);

            manageEmployeeData = JsonConvert.SerializeObject(manageEmployeeData);
            if (manageEmployeeData.ToString() == "[]")
            {
                await context.insert(manageEmployee);

                return(true);
            }

            return(false);
        }
示例#5
0
        // GET api/employee/5
        //public IHttpActionResult Get(int id)
        //{
        //    try {
        //        return Ok(ManageEmployee.GetDetails(id));
        //    }
        //    catch(Exception e)
        //    {
        //        return BadRequest();
        //    }
        //}

        // POST api/employee
        /// <summary>
        /// This method retrieves the Employee object from the body of the incoming POST request and
        /// uses the Manage Employee service to insert the employee into the database. It also returns
        /// the calculated salary
        /// </summary>
        /// <param name="emp">
        /// Body of the incoming POST request
        /// </param>
        /// <returns>
        /// Calculated salary with 200 status on Success,
        /// Exception with 500 status on Failure
        /// </returns>
        public IHttpActionResult Post([FromBody] Employee emp)
        {
            try
            {
                float result = ManageEmployee.createEmployee(emp);
                if (result != -1)
                {
                    return(Ok(result));
                }
                return(Content(HttpStatusCode.Conflict, "Employee record already exists"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.ToString()));
            }
        }
示例#6
0
        private void manageEmployeesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(ManageEmployee))
                {
                    form.Activate();
                    return;
                }
            }
            ManageEmployee manageEmployee = new ManageEmployee
            {
                MdiParent = this
            };

            manageEmployee.Show();
        }
示例#7
0
 // GET: Employee
 public ActionResult Index()
 {
     ViewBag.employee = ManageEmployee.Get();
     return(View("Employee"));
 }
        public int UpdateEmployee(ManageEmployee emp)
        {
            int id = objmodel.SaveEmployee(emp);

            return(id);
        }
        public async Task <ActionResult> updateEmployee([FromBody] ManageEmployee manageEmployee)
        {
            await context.update(manageEmployee.employeeEmail, manageEmployee);

            return(NoContent());
        }
示例#10
0
        private void btnEmployee_Click(object sender, EventArgs e)
        {
            ManageEmployee frmMGEMployee = new ManageEmployee();

            frmMGEMployee.ShowDialog();
        }