Exemple #1
0
        public IHttpActionResult GetMarker_Type(int id)
        {
            db.Configuration.ProxyCreationEnabled = false;
            Marker_Type marker_Type = db.Marker_Type.Find(id);

            if (marker_Type == null)
            {
                return(Ok(1));
            }

            return(Ok(marker_Type));
        }
Exemple #2
0
        public IHttpActionResult DeleteMarker_Type(int id)
        {
            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                Marker_Type marker_Type = db.Marker_Type.Find(id);
                if (marker_Type == null)
                {
                    return(Ok(1));
                }

                db.Marker_Type.Remove(marker_Type);
                db.SaveChanges();

                return(Ok(marker_Type));
            }
            catch
            {
                return(Ok(2));
            }
        }
Exemple #3
0
        public IHttpActionResult PostMarker_Type(Marker_Type marker_Type)
        {
            db.Configuration.ProxyCreationEnabled = false;
            //try
            //{
            //    if (db.Marker_Type.Contains(marker_Type))
            //    {
            //        return Ok(1);
            //    }
            //    else
            //    {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Marker_Type.Add(marker_Type);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = marker_Type.Marker_Type_ID }, marker_Type));
        }
Exemple #4
0
        public IHttpActionResult PutMarker_Type(int id, Marker_Type marker_Type)
        {
            db.Configuration.ProxyCreationEnabled = false;
            try {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (id != marker_Type.Marker_Type_ID)
                {
                    return(BadRequest());
                }

                db.Entry(marker_Type).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Marker_TypeExists(id))
                    {
                        return(Ok(1));
                    }
                    else
                    {
                        throw;
                    }
                }

                return(StatusCode(HttpStatusCode.NoContent));
            }
            catch
            {
                return(Ok(2));
            }
        }