예제 #1
0
        public IHttpActionResult PutHoursWork(int id, HoursWork hoursWork)
        {
            if (id != hoursWork.EmployeeId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult PostHoursWork(HoursWork hoursWork)
        {
            db.HoursWorks.Add(hoursWork);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = hoursWork.EmployeeId }, hoursWork));
        }
예제 #3
0
        public IHttpActionResult GetHoursWork(int id)
        {
            HoursWork hoursWork = db.HoursWorks.Find(id);

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

            return(Ok(hoursWork));
        }
예제 #4
0
        public IHttpActionResult DeleteHoursWork(int id)
        {
            HoursWork hoursWork = db.HoursWorks.Find(id);

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

            db.HoursWorks.Remove(hoursWork);
            db.SaveChanges();

            return(Ok(hoursWork));
        }