Exemple #1
0
        public IHttpActionResult PutType(int id, RentApp.Models.Entities.Type type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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



            try
            {
                unitOfWork.Types.Update(type);
                unitOfWork.Complete();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        public IHttpActionResult GetType(int id)
        {
            RentApp.Models.Entities.Type type = unitOfWork.Types.Get(id);
            if (type == null)
            {
                return(NotFound());
            }

            return(Ok(type));
        }
Exemple #3
0
        public IHttpActionResult PostType(RentApp.Models.Entities.Type type)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            unitOfWork.Types.Add(type);
            unitOfWork.Complete();

            return(CreatedAtRoute("DefaultApi", new { id = type.Id }, type));
        }
Exemple #4
0
        public IHttpActionResult DeleteType(int id)
        {
            RentApp.Models.Entities.Type type = unitOfWork.Types.Get(id);
            if (type == null)
            {
                return(NotFound());
            }

            unitOfWork.Types.Remove(type);
            unitOfWork.Complete();

            return(Ok(type));
        }