예제 #1
0
        // GET api/values/5
        public HttpResponseMessage Get(int id)
        {
            DataManager.ConnectionString = connectionString;
            HttpResponseMessage response = null;
            try
            {
                    project pr = DataManager.GetProjectByID(id);

                    serProject prj = new serProject();
                    prj.Created = pr.Created;// == null ? DateTime.MinValue : (DateTime)pr.Created;
                    prj.Description = pr.Description;
                    prj.ID = pr.ID;
                    prj.JobNumber = pr.JobNumber;
                    prj.Notes = pr.Notes;

                response = Request.CreateResponse(HttpStatusCode.OK, prj);
                response.Headers.CacheControl = new CacheControlHeaderValue()
                {
                    MaxAge = TimeSpan.FromMinutes(20)
                };
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return response;
        }
예제 #2
0
        public HttpResponseMessage Get()
        {
            List<serProject> projects = new List<serProject>();
               DataManager.ConnectionString = connectionString;
               HttpResponseMessage response = null;
               try
               {
               IEnumerable<project> prjs = DataManager.GetProjects();
               foreach (project pr in prjs)
               {
                   serProject prj = new serProject();
                   prj.Created = pr.Created;// == null ? DateTime.MinValue : (DateTime)pr.Created;
                   prj.Description = pr.Description;
                   prj.ID = pr.ID;
                   prj.JobNumber = pr.JobNumber;
                   prj.Notes = pr.Notes;
                   projects.Add(prj);
               }

               response = Request.CreateResponse(HttpStatusCode.OK, projects);
               response.Headers.CacheControl = new CacheControlHeaderValue()
               {
                   MaxAge = TimeSpan.FromMinutes(20)
               };
               }
               catch (Exception ex)
               {
               response = Request.CreateResponse(HttpStatusCode.InternalServerError);
               }
               return response;
        }