Beispiel #1
0
        public IHttpActionResult PutLeave_Type(int id, Leave_Type leave_Type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != leave_Type.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult PostLeave_Type(Leave_Type leave_Type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Leave_Type.Add(leave_Type);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (Leave_TypeExists(leave_Type.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = leave_Type.ID }, leave_Type));
        }
Beispiel #3
0
        public IHttpActionResult GetLeave_Type(int id)
        {
            Leave_Type leave_Type = db.Leave_Type.Find(id);

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

            return(Ok(leave_Type));
        }
Beispiel #4
0
        public IHttpActionResult DeleteLeave_Type(int id)
        {
            Leave_Type leave_Type = db.Leave_Type.Find(id);

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

            db.Leave_Type.Remove(leave_Type);
            db.SaveChanges();

            return(Ok(leave_Type));
        }
 public bool Update(Leave_Type entity)
 {
     _db.Leave_Types.Update(entity);
     return(save());
 }
 public bool Delete(Leave_Type entity)
 {
     _db.Leave_Types.Remove(entity);
     return(save());
 }
 public bool create(Leave_Type entity)
 {
     _db.Leave_Types.Add(entity);
     return(save());
 }