Пример #1
0
        public IHttpActionResult PostCurrentStatu(CurrentStatu currentStatu)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CurrentStatus.Add(currentStatu);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (CurrentStatuExists(currentStatu.CurrentStatus))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = currentStatu.CurrentStatus }, currentStatu));
        }
Пример #2
0
        public IHttpActionResult PutCurrentStatu(string id, CurrentStatu currentStatu)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != currentStatu.CurrentStatus)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public IHttpActionResult GetCurrentStatu(string id)
        {
            CurrentStatu currentStatu = db.CurrentStatus.Find(id);

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

            return(Ok(currentStatu));
        }
Пример #4
0
        public IHttpActionResult DeleteCurrentStatu(string id)
        {
            CurrentStatu currentStatu = db.CurrentStatus.Find(id);

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

            db.CurrentStatus.Remove(currentStatu);
            db.SaveChanges();

            return(Ok(currentStatu));
        }