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)); }
public IHttpActionResult GetType(int id) { RentApp.Models.Entities.Type type = unitOfWork.Types.Get(id); if (type == null) { return(NotFound()); } return(Ok(type)); }
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)); }
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)); }