Ejemplo n.º 1
0
        public async Task <IActionResult> PutAdminEmployee(string id, AdminEmployee adminEmployee)
        {
            if (id != adminEmployee.AdminID)
            {
                return(BadRequest());
            }

            _context.Entry(adminEmployee).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AdminEmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public IHttpActionResult PutAdminEmployee(int id, AdminEmployee adminEmployee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != adminEmployee.EmployeeId)
            {
                return(BadRequest());
            }

            db.Entry(adminEmployee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AdminEmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetAdminEmployee(int id)
        {
            AdminEmployee adminEmployee = db.AdminEmployee.Find(id);

            if (adminEmployee == null)
            {
                return(NotFound());
            }

            return(Ok(adminEmployee));
        }
Ejemplo n.º 4
0
        public IHttpActionResult PostAdminEmployee(AdminEmployee adminEmployee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AdminEmployee.Add(adminEmployee);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = adminEmployee.EmployeeId }, adminEmployee));
        }
Ejemplo n.º 5
0
        public IHttpActionResult DeleteAdminEmployee(int id)
        {
            AdminEmployee adminEmployee = db.AdminEmployee.Find(id);

            if (adminEmployee == null)
            {
                return(NotFound());
            }

            db.AdminEmployee.Remove(adminEmployee);
            db.SaveChanges();

            return(Ok(adminEmployee));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <AdminEmployee> > PostAdminEmployee(AdminEmployee adminEmployee)
        {
            _context.AdminEmployee.Add(adminEmployee);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (AdminEmployeeExists(adminEmployee.AdminID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetAdminEmployee", new { id = adminEmployee.AdminID }, adminEmployee));
        }
Ejemplo n.º 7
0
        static void Main_HRDemo(string[] args)
        {
            BaseEmployee be = new AdminEmployee();

            be.Print();

            be = new FacultyEmployee()
            {
                EmployeeID = 1,
                FirstName  = "Abdul",
                LastName   = "Makid"
            };
            be.Print();

            be = new ContractEmployee()
            {
                Hours = 300,
                Rate  = 18
            };

            be.Print();
            Console.ReadKey();
        }