Example #1
0
        public IHttpActionResult PutMahatma(int id, Mahatma mahatma)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mahatma.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void Delete(int Id)
        {
            Mahatma oMahatma = dbContext.Mahatma.Find(Id);

            dbContext.Mahatma.Remove(oMahatma);
            Save();
        }
Example #3
0
        public IHttpActionResult GetMahatma(int id)
        {
            Mahatma mahatma = db.Mahatmas.Find(id);

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

            return(Ok(mahatma));
        }
Example #4
0
        public IHttpActionResult PostMahatma(Mahatma mahatma)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Mahatmas.Add(mahatma);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = mahatma.Id }, mahatma));
        }
Example #5
0
        public IHttpActionResult DeleteMahatma(int id)
        {
            Mahatma mahatma = db.Mahatmas.Find(id);

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

            db.Mahatmas.Remove(mahatma);
            db.SaveChanges();

            return(Ok(mahatma));
        }
 public void Update(Mahatma obj)
 {
     dbContext.Entry(obj).State = EntityState.Modified;
     Save();
 }
 public void Insert(Mahatma obj)
 {
     dbContext.Mahatma.Add(obj);
     Save();
 }