public async Task<HttpResponseMessage> Update(Guid id, ReviewModel model) { try { ReviewModel result = AutoMapper.Mapper.Map<ReviewModel>(await service.UpdateAsync(AutoMapper.Mapper.Map<IReview>(model))); if (result == null) return Request.CreateResponse(HttpStatusCode.BadRequest, "Error while updating review."); else return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
public async Task<HttpResponseMessage> Insert(ReviewModel model) { try { ReviewModel result = AutoMapper.Mapper.Map<ReviewModel>(await service.AddAsync(AutoMapper.Mapper.Map<IReview>(model))); if (result == null) return Request.CreateResponse(HttpStatusCode.BadRequest, "Failed."); else return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }