Пример #1
0
        public static int CreateProject(project prj)
        {
            int id = -1;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);
            try
            {
                context.projects.InsertOnSubmit(prj);
                context.SubmitChanges();
                id = prj.ID;
            }
            catch (Exception ex)
            {

            }
            return id;
        }
Пример #2
0
 // PUT api/values/5
 public HttpResponseMessage Put(int id, [FromBody]serProject prj)
 {
     bool sucessful = false;
     DataManager.ConnectionString = connectionString;
     if (prj != null)
     {
         project project = new project()
         {
             ID=prj.ID,
             Description = prj.Description,
             Notes = prj.Notes,
             JobNumber = prj.JobNumber,
             Created = prj.Created == DateTime.MinValue ? (DateTime?)null : prj.Created
         };
         sucessful = DataManager.UpdateProject(project);
     }
     if (sucessful)
     {
         return Request.CreateResponse(HttpStatusCode.OK);
     }
     else
     {
         return Request.CreateResponse(HttpStatusCode.InternalServerError);
     }
 }
Пример #3
0
        // POST api/values
        public HttpResponseMessage Post([FromBody]serProject prj)
        {
            DataManager.ConnectionString = connectionString;
            int id = -1;
            if (prj != null)
            {
                project project = new project()
                {
                    Description = prj.Description,
                    Notes = prj.Notes,
                    JobNumber = prj.JobNumber,
                    Created = DateTime.Now
                };

                id = DataManager.CreateProject(project);
            }

            if (id > -1)
            {
                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
        }
Пример #4
0
 partial void Deleteproject(project instance);
Пример #5
0
 partial void Updateproject(project instance);
Пример #6
0
 partial void Insertproject(project instance);
Пример #7
0
        public static bool UpdateProject(project prj)
        {
            bool sucessful = false;
            SanityDataModelDataContext context = new SanityDataModelDataContext(ConnectionString);

            var qry = from P in context.projects
                      where P.ID == prj.ID
                      select P;

            project p = qry.FirstOrDefault();
            if(p!=null)
            {
                p.Created = prj.Created;
                p.Description = prj.Description;
                p.JobNumber = prj.JobNumber;
                p.Notes = prj.Notes;

                context.SubmitChanges();
                sucessful = true;
            }

            return sucessful;
        }