コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }