Пример #1
0
        public IHttpActionResult PostRloe(Rloe rloe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            rloe.CreateTime = DateTime.Now;
            _rloerepository.Insert(rloe);

            return(CreatedAtRoute("DefaultApi", new { id = rloe.Id }, rloe));
        }
Пример #2
0
        public IHttpActionResult GetRloe(int id)
        {
            Rloe rloe = _rloerepository.Get(id);

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

            return(Ok(rloe));
        }
Пример #3
0
        public IHttpActionResult PutRloe(int id, Rloe rloe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            try
            {
                _rloerepository.Update(rloe, id);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }