示例#1
0
        public IHttpActionResult CompanyCreate([FromBody] EnterpriseCreateModel model)
        {
            long?id = 0;

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("The model is not valid"));
                }

                var service = new PumoxService();
                id = service.CompanyCreate(model).Result;
                if (id == null)
                {
                    return(InternalServerError());
                }

                return(Json(id));
            }
            catch (HttpException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)));
            }
        }
示例#2
0
 public IHttpActionResult EnterpriseGetAll()
 {
     try
     {
         var service = new PumoxService();
         var result  = service.EnterpriseGetAll().Result;
         return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, result)));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
         return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)));
     }
 }
示例#3
0
        public IHttpActionResult EnterpriseGet(int id)
        {
            try
            {
                var service         = new PumoxService();
                var enterpriseModel = service.EnterpriseGet(id).Result;
                if (enterpriseModel == null)
                {
                    return(NotFound());
                }

                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, service.EnterpriseGet(id).Result)));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)));
            }
        }
示例#4
0
        public IHttpActionResult EnterpriseDelete(long id)
        {
            try
            {
                var service = new PumoxService();
                var deleted = service.EnterpriseDelete(id).Result;
                if (!deleted)
                {
                    return(NotFound());
                }

                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, "Enterprise has been deleted")));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)));
            }
        }
示例#5
0
        public IHttpActionResult EnterpriseUpdate(long id, [FromBody] EnterpriseUpdateModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("The model is not valid"));
                }

                var service      = new PumoxService();
                var enterpriseId = service.EnterpriseUpdate(id, model).Result;
                if (enterpriseId == null)
                {
                    return(NotFound());
                }

                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, enterpriseId)));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)));
            }
        }