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)); }
public async Task <IHttpActionResult> GetPensionService(int id) { PensionService pensionService = await db.PensionServices.FindAsync(id); if (pensionService == null) { return(NotFound()); } return(Ok(pensionService)); }
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)); }
public async Task <IHttpActionResult> DeletePensionService(int id) { PensionService pensionService = await db.PensionServices.FindAsync(id); if (pensionService == null) { return(NotFound()); } db.PensionServices.Remove(pensionService); await db.SaveChangesAsync(); return(Ok(pensionService)); }
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); }