public async Task<IHttpActionResult> PutLogisticInfo(int id, LogisticInfo logisticInfo)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != logisticInfo.LogisticInfoId)
            {
                return BadRequest();
            }

            db.Entry(logisticInfo).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LogisticInfoExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task<IHttpActionResult> GetLogisticInfo(int id)
        {
            LogisticInfo logisticInfo = await db.LogisticInfoes.FindAsync(id);
            if (logisticInfo == null)
            {
                return NotFound();
            }

            return Ok(logisticInfo);
        }
        public async Task<IHttpActionResult> DeleteLogisticInfo(int id)
        {
            LogisticInfo logisticInfo = await db.LogisticInfoes.FindAsync(id);
            if (logisticInfo == null)
            {
                return NotFound();
            }

            db.LogisticInfoes.Remove(logisticInfo);
            await db.SaveChangesAsync();

            return Ok(logisticInfo);
        }
        public async Task<IHttpActionResult> PostLogisticInfo(LogisticInfo logisticInfo)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.LogisticInfoes.Add(logisticInfo);
            await db.SaveChangesAsync();
            ;

            return CreatedAtRoute("DefaultApi", new { id = logisticInfo.LogisticInfoId }, logisticInfo);
        }
Example #5
0
        public async Task <IHttpActionResult> AddLogisticInfo(int LogisticID, [FromBody] LogisticInfo logisticInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Logistic logistic = await db.Logistics.FindAsync(LogisticID);

            if (logistic == null)
            {
                return(NotFound());
            }
            logisticInfo.LogisticID = logistic.LogisticID;
            db.LogisticInfoes.Add(logisticInfo);
            await db.SaveChangesAsync();

            var httpResp = Request.CreateResponse(HttpStatusCode.NoContent);

            return(ResponseMessage(httpResp));
        }