コード例 #1
0
        public HttpResponseMessage Edit(Data.EFModels.RepricingInformation repricingInformation)
        {
            if (repricingInformation == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "RepricingInformation object cannot be null."));
            }

            using (AmazonMWSdb amazonMwSdb = m_amazonMwSdbService.GetContextInstance())
            {
                if (repricingInformation.RepricingInformationId == 0)
                {
                    RepricingInformation repricingInformationCreated = amazonMwSdb.RepricingInformations.Add(repricingInformation);
                    amazonMwSdb.SaveChanges();

                    repricingInformation = repricingInformationCreated;
                }
                else
                {
                    amazonMwSdb.RepricingInformations.Attach(repricingInformation);
                    var entry = amazonMwSdb.Entry(repricingInformation);
                    entry.State = EntityState.Modified;
                    amazonMwSdb.SaveChanges();
                }

                return(Request.CreateResponse(HttpStatusCode.OK, repricingInformation));
            }
        }
コード例 #2
0
        public HttpResponseMessage Get([FromUri] long repricingInformationId)
        {
            using (AmazonMWSdb amazonMwSdb = m_amazonMwSdbService.GetContextInstance())
            {
                Data.EFModels.RepricingInformation repricingInformation = amazonMwSdb.RepricingInformations.SingleOrDefault(s => s.RepricingInformationId == repricingInformationId);

                return(Request.CreateResponse(HttpStatusCode.OK, repricingInformation));
            }
        }