public async Task <HttpResponseMessage> GetById(int id) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid data")); } VehicleModelServ vehicleModel = await VehicleModelService.GetById(id); VehicleModel model = mapper.Map <VehicleModel>(vehicleModel); return(Request.CreateResponse(HttpStatusCode.OK, model)); }
public async Task <HttpResponseMessage> Add(VehicleModel vehicleModel) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid data")); } VehicleModelServ vehicleModelServ = mapper.Map <VehicleModelServ>(vehicleModel); bool provjera = await VehicleModelService.Add(vehicleModelServ); if (provjera) { return(Request.CreateResponse(HttpStatusCode.OK, "Vehicle model is successfully created!")); } else { return(Request.CreateResponse(HttpStatusCode.Conflict, "Vehicle model is not created!")); } }