// GET: Emp
        public ActionResult Index()
        {
            EmpDbHandle dbhandle = new EmpDbHandle();

            ModelState.Clear();
            return(View(dbhandle.GetEmployee()));
        }
Ejemplo n.º 2
0
        public List <Employee> Get()
        {
            EmpDbHandle     dbhandle = new EmpDbHandle();
            List <Employee> li       = new List <Employee>();

            li = dbhandle.GetAll();
            return(li);
        }
        public ActionResult Edit(int id, Employee em)
        {
            try
            {
                EmpDbHandle edb = new EmpDbHandle();
                edb.UpdateEmployeeDetails(em);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult Put(int id, Employee emp)
        {
            EmpDbHandle dbhandle = new EmpDbHandle();

            try
            {
                dbhandle.UpdateEmp(emp, id);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.BadRequest, "Update Failure"));
            }
        }
Ejemplo n.º 5
0
        public IHttpActionResult Post(Employee emp)
        {
            EmpDbHandle dbhandle = new EmpDbHandle();

            try
            {
                dbhandle.AddEmp(emp);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.BadRequest, "Post Failure"));
            }
        }
Ejemplo n.º 6
0
        public HttpResponseMessage delete(int id)
        {
            EmpDbHandle dbHandle = new EmpDbHandle();

            try
            {
                dbHandle.DeleteEmp(id);
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
                //   return Content(HttpStatusCode.BadRequest, "Delete Failure");
            }
        }
 // GET: Emp/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         EmpDbHandle edb = new EmpDbHandle();
         if (edb.DeleteEmployeeDetails(id))
         {
             ViewBag.AlertMsg = "Employee Deleted Successfully";
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Create(Employee em)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmpDbHandle edb = new EmpDbHandle();
                    if (edb.AddEmployee(em))
                    {
                        ViewBag.Message = "Employee Details Added Successfully";
                        ModelState.Clear();
                    }
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }
        // GET: Emp/Edit/5
        public ActionResult Edit(int id)
        {
            EmpDbHandle edb = new EmpDbHandle();

            return(View(edb.GetEmployee().Find(em => em.id == id)));
        }