コード例 #1
0
        // PUT api/EmployeeAttendance/5
        public IHttpActionResult PutEmpAttendanceRegister(int id, EmpAttendanceRegister empattendanceregister)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != empattendanceregister.AttandanceId)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public IHttpActionResult PostEmpAttendanceRegister(EmpAttendanceRegister empattendanceregister)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.EmpAttendanceRegisters.Add(empattendanceregister);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = empattendanceregister.AttandanceId }, empattendanceregister);
        }