コード例 #1
0
        public async Task<IHttpActionResult> PutPensionService(int id, PensionService pensionService)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != pensionService.PensionServiceNo)
            {
                return BadRequest();
            }

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

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

            return StatusCode(HttpStatusCode.NoContent);
        }
コード例 #2
0
        public async Task<IHttpActionResult> PostPensionService(PensionService pensionService)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.PensionServices.Add(pensionService);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = pensionService.PensionServiceNo }, pensionService);
        }
コード例 #3
0
        private async Task<List<PensionService>> AddPensionService(Pension pension, string service)
        {
            List<PensionService> pensionServices = new List<PensionService>();
            var arr = HttpUtility.UrlDecode(service.ToString()).Split(',');

            for (int i = 0; i < arr.Length; i++)
            {
                PensionService pensionService = new PensionService();
                pensionService.PensionNo = pension.PensionNo;
                pensionService.PensionServiceCode = int.Parse(arr[i].ToString());
                pensionServices.Add(pensionService);
            }

            db.PensionServices.AddRange(pensionServices);
            await db.SaveChangesAsync();

            return pensionServices;
        }