コード例 #1
0
        public HttpResponseMessage Save(EducationModel aEducationModel)
        {
            IUnitOfWork          uWork            = new UnitOfWork();
            IEducationRepository Education        = new EducationRepository(uWork);
            IEducationService    educationService = new EducationService(Education);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var educationModelList = educationService.SaveEducation(aEducationModel);
                    if (educationModelList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, educationModelList));
                    }
                    else
                    {
                        string message = "Error Saving Data";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
            }
        }
コード例 #2
0
 public IHttpActionResult SaveEducation(EducationModel education)
 {
     try
     {
         return(Ok(_educationService.SaveEducation(education)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }