public bool UpdInsuranceById(Insurance insurance, int id) { bool validationBusiness; try { CoveringType coveringType = _coveringTypeRepository.GetbyId(insurance.CoveringTypeId); int riskType = insurance.RiskTypeId; if (riskType == 4 && coveringType.Percentage > 50) { validationBusiness = false; } else { validationBusiness = _insuranceRepository.UpdInsuranceById(insurance, id); } return(validationBusiness); } catch (Exception e) { throw e; } }
public async Task <IActionResult> PutCoveringType([FromRoute] int id, [FromBody] CoveringType coveringType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != coveringType.Id) { return(BadRequest()); } _context.Entry(coveringType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoveringTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Name")] CoveringType coveringType) { if (ModelState.IsValid) { _context.Add(coveringType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(coveringType)); }
public async Task <IActionResult> PostCoveringType([FromBody] CoveringType coveringType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CoveringTypes.Add(coveringType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCoveringType", new { id = coveringType.Id }, coveringType)); }
public bool ValidateInsurance(int idCoveringType, int idRiskType) { bool valida = true; CoveringType coveringType = _coveringTypeRepository.GetbyId(idCoveringType); int riskType = idRiskType; if (riskType == 4 && coveringType.Percentage > 50) { valida = false; } return(valida); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] CoveringType coveringType) { if (id != coveringType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(coveringType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { } return(RedirectToAction(nameof(Index))); } return(View(coveringType)); }