public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] HcpCenter hcpCenter) { if (id != hcpCenter.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hcpCenter); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HcpCenterExists(hcpCenter.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(hcpCenter)); }
public async Task <IActionResult> PutHcpCenter([FromRoute] int id, [FromBody] HcpCenter hcpCenter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hcpCenter.Id) { return(BadRequest()); } _context.Entry(hcpCenter).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HcpCenterExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> GetHcpByIdCulture([FromRoute] int id, [FromRoute] string culture) { var cultureId = _context.Culture.Where(x => x.Name == culture).Select(x => x.Id).SingleOrDefault(); HcpCenter res = await _context.HcpCenters.Where(x => x.Id == id).Include(z => z.HcpCenterTraslation).FirstOrDefaultAsync(); HcpCenterTraslation res1 = res.HcpCenterTraslation.Where(x => x.CultureId == cultureId).FirstOrDefault(); return(Ok(res1)); }
public async Task <IActionResult> Create([Bind("Id,Name")] HcpCenter hcpCenter) { if (ModelState.IsValid) { _context.Add(hcpCenter); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hcpCenter)); }
public async Task <IActionResult> PostHcpCenter([FromBody] HcpCenter hcpCenter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.HcpCenters.Add(hcpCenter); await _context.SaveChangesAsync(); return(CreatedAtAction("GetHcpCenter", new { id = hcpCenter.Id }, hcpCenter)); }