Пример #1
0
        public IHttpActionResult PutEmployye(int id, Employye employye)
        {
            if (id != employye.EmployeeID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostEmployye(Employye employye)
        {
            db.Employye.Add(employye);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = employye.EmployeeID }, employye));
        }
Пример #3
0
        public IHttpActionResult DeleteEmployye(int id)
        {
            Employye employye = db.Employye.Find(id);

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

            db.Employye.Remove(employye);
            db.SaveChanges();

            return(Ok(employye));
        }
Пример #4
0
        public IHttpActionResult PostEmployye(Employye employye)
        {
            db.Employye.Add(employye);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (EmployyeExists(employye.EmployeeID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = employye.EmployeeID }, employye));
        }