Пример #1
0
        public IHttpActionResult PutSewadar(int id, Sewadar sewadar)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public void Delete(int id)
        {
            Sewadar sewadar = db.Sewadar.Find(id);

            db.Sewadar.Remove(sewadar);
            Save();
        }
Пример #3
0
        public IHttpActionResult GetSewadar(int id)
        {
            Sewadar sewadar = db.Sewadars.Find(id);

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

            return(Ok(sewadar));
        }
Пример #4
0
        public IHttpActionResult PostSewadar(Sewadar sewadar)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Sewadars.Add(sewadar);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = sewadar.ID }, sewadar));
        }
Пример #5
0
        public IHttpActionResult DeleteSewadar(int id)
        {
            Sewadar sewadar = db.Sewadars.Find(id);

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

            db.Sewadars.Remove(sewadar);
            db.SaveChanges();

            return(Ok(sewadar));
        }
Пример #6
0
 public void Update(Sewadar obj)
 {
     db.Entry(obj).State = EntityState.Modified;
     Save();
 }
Пример #7
0
 public void Insert(Sewadar obj)
 {
     db.Sewadar.Add(obj);
     Save();
 }