using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Sainaatech;
namespace HRMS.Controllers
{
    
    public class EmpoyeeLoginController : ApiController
    {
        [Route("EmpoyeeLoginController")]
        [HttpGet]
        public IEnumerable<tblEmployeeMaster> Get()
        {
            using (HMS entities = new HMS())
            {
                return entities.tblEmployeeMasters.ToList();
            }
        }
        [HttpGet]
        [Route("EmpoyeeLoginController/{id}")]
        public IHttpActionResult GetEmployeeById(int id)
        {
            using (HMS entities = new HMS())
            {
                var employee = entities.tblEmployeeMasters
                    .Where(e => e.EUid == id && e.Status == "Active")
                    .Select(e => new
                    {
                        e.Name,
                        e.Email
                    })
                    .FirstOrDefault();

                if (employee == null)
                {
                    return Content(HttpStatusCode.NotFound, "Employee not found or inactive.");
                }

                return Ok(employee); // Return the employee data
            }
        }
    }
}
