コード例 #1
0
        public HttpResponseMessage Put(int id, [FromBody] PurpPersonal purppersonal)
        {
            try
            {
                using (TrustyloandbEntities entities = new TrustyloandbEntities())
                {
                    var entity = entities.PurpPersonals.FirstOrDefault(e => e.P_ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Person with P_Id " + id.ToString() + " Not Found!"));
                    }
                    else
                    {
                        entity.Ppu_Reason = purppersonal.Ppu_Reason;


                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
コード例 #2
0
        public HttpResponseMessage Post([FromBody] PurpPersonal purppersonal)
        {
            try
            {
                using (TrustyloandbEntities entities = new TrustyloandbEntities())
                {
                    entities.Configuration.ProxyCreationEnabled = false;
                    entities.PurpPersonals.Add(purppersonal);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, purppersonal);
                    message.Headers.Location = new Uri(Request.RequestUri + purppersonal.ID.ToString());
                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }