public async Task <IActionResult> PutIssuerAll(Guid id, IssuerAll issuerAll) { if (id != issuerAll.IsId) { return(BadRequest()); } _context.Entry(issuerAll.Issuer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!IssuerAllExist(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <IssuerAll> > GetIssuerAllDetail(Guid id) { Issuer isu = await _context.Issuer.FindAsync(id); IssuerAll issuerAll = new IssuerAll(); issuerAll.IsId = isu.IsId; issuerAll.Issuer = isu; issuerAll.IssuerAttrs = await _context.IssuerAttr.Where(i => i.IsId == isu.IsId).ToListAsync(); if (issuerAll.IsId == null) { return(NotFound()); } return(issuerAll); }
public async Task <ActionResult <IssuerAll> > PostIssuerAll([FromBody] IssuerAll issuerAll) { issuerAll.IsId = Guid.NewGuid(); issuerAll.Issuer.IsId = issuerAll.IsId; _context.Issuer.Add(issuerAll.Issuer); await _context.SaveChangesAsync(); foreach (IssuerAttr item in issuerAll.IssuerAttrs) { item.IsId = issuerAll.IsId; _context.IssuerAttr.Add(item); await _context.SaveChangesAsync(); } return(CreatedAtAction("GetIssuerAllDetail", new { id = issuerAll.IsId }, issuerAll)); //return CreatedAtAction("", new { id = issuerAll.IsId }, issuelAll); }
public async Task <ActionResult <IssuerAll> > DeleteIssuerAll(Guid id) { Issuer isu = await _context.Issuer.FindAsync(id); IssuerAll issuerAll = new IssuerAll(); issuerAll.IsId = isu.IsId; issuerAll.Issuer = isu; issuerAll.IssuerAttrs = await _context.IssuerAttr.Where(i => i.IsId == isu.IsId).ToListAsync(); if (issuerAll == null) { return(NotFound()); } _context.Issuer.Remove(isu); await _context.SaveChangesAsync(); return(issuerAll); }
public async Task <ActionResult <IEnumerable <IssuerAll> > > GetIssuerAll(int skip, int take) { List <Issuer> isu = await _context.Issuer.Skip(skip).Take(take).ToListAsync(); List <IssuerAll> isAll = new List <IssuerAll>(); foreach (Issuer data in isu) { IssuerAll isAllElement = new IssuerAll(); isAllElement.IsId = data.IsId; isAllElement.Issuer = data; List <IssuerAttr> isAttrList = new List <IssuerAttr>(); isAttrList = await _context.IssuerAttr.Where(isu => isu.IsId == data.IsId).ToListAsync(); isAllElement.IssuerAttrs = isAttrList; isAll.Add(isAllElement); } return(isAll); }