private void CheckIsNull(TipoExame entity) { if (entity is null) { throw new ServiceException("Tipo Exame não encontrado"); } }
private void CheckNotContains(TipoExame entity) { if (_repository.Find(entity.TipoExameId) is null) { throw new ServiceException("Tipo Exame não cadastrado"); } }
public ExameTeste() { _faker = new Faker(); _nome = _faker.Random.Word(); _tipo = TipoExame.AnaliseClinica; _status = Status.Ativo; }
protected void btnCadastrarTipoExame(object sender, EventArgs e) { try { TipoExame estado = new TipoExame(); estado.Descricao = descricao.Text; TipoExameDal estadoDal = new TipoExameDal(); estadoDal.Salvar(estado); descricao.Text = ""; string msg = "Tipo de Exame : " + estado.Descricao + " - " + " foi cadastrado com sucesso"; lblMensagem.Text = msg; lblMensagem.Attributes.CssStyle.Add("color", "green"); // Response.Redirect("/Pages/EstadoCadastro.aspx"); //lblMensagem.Attributes.CssStyle.Add("color", "red"); } catch (Exception erro) { lblMensagem.Text = erro.ToString(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nometipo,Descricao")] TipoExame tipoExame) { if (id != tipoExame.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipoExame); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoExameExists(tipoExame.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoExame)); }
public void Update(TipoExame entity) { CheckIsNull(entity); entity.Validate(); CheckContainsByNome(entity); _repository.Update(entity); }
/// <summary> /// Verifica se o campo obrigátorio não foi preenchido. /// </summary> /// <param name="entity">Objeto com o campo a ser verificado.</param> /// <returns>True se o campo Nome não estiver preenchido ou False se ele estiver.</returns> public static bool Verificar(TipoExame entity) { if (String.IsNullOrWhiteSpace(entity.Nome)) { return(true); } return(false); }
public ActionResult DeleteConfirmar(int id) { TipoExame tipoExame = db.TipoExames.Find(id); db.TipoExames.Remove(tipoExame); db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult DeleteConfirmed(int id) { TipoExame tipoExame = db.TiposExames.Find(id); db.TiposExames.Remove(tipoExame); db.SaveChanges(); db.Dispose(); return(RedirectToAction("Index")); }
public FabricaDeAgendamento InformarExame(string codigo, string descricao, double preco) { TipoExame tipoExame = new TipoExame(codigo, descricao); Exame exame = new Exame(Guid.NewGuid(), tipoExame, preco); _Agendamento.AdicionarExame(exame); return(this); }
private void CheckContainsByNome(TipoExame entity) { var entityByNome = _repository.FindByNome(entity.Nome); if (!(entityByNome is null) && entity.TipoExameId != entityByNome.TipoExameId) { throw new ServiceException("Tipo Exame já cadastrado"); } }
/// <summary> /// Verifica se o tamanho dos campos do objeto excedem o limite estabelecido no banco de dados. /// </summary> /// <param name="entity">Contêm os dados do campo.</param> /// <returns> /// True se algum campo possuir mais caracteres do que o limite declarado no banco de dados ou /// False caso todos os campos respeitem esta especificação. /// </returns> public static bool Verificar(TipoExame entity) { if (entity.Nome.Length > 50) { return(true); } return(false); }
public Exame(string nome, TipoExame tipo, Status status) { AddNotifications(new ValidationContract() .HasMinLen(nome, 3, "Nome", Mensagens.NomeInvalido)); Nome = nome; Tipo = tipo; Status = status; }
public ActionResult Edit([Bind(Include = "Id,TipodoExame,Descricao")] TipoExame tipoExame) { if (ModelState.IsValid) { db.Entry(tipoExame).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoExame)); }
public void Remove(TipoExame entity) { try { _data.Remove(entity); } catch (System.Exception ex) { throw new RepositoryException(ex); } }
public ActionResult Create([Bind(Include = "Id,TipodoExame,Descricao")] TipoExame tipoExame) { if (ModelState.IsValid) { db.TipoExames.Add(tipoExame); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tipoExame)); }
public async Task <IActionResult> Create([Bind("Id,Nometipo,Descricao")] TipoExame tipoExame) { if (ModelState.IsValid) { _context.Add(tipoExame); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipoExame)); }
public IActionResult Put([FromRoute] int id, [FromBody] TipoExameInput input) { var objTipoExame = new TipoExame() { Nome = input.Nome }; var obj = _tipoExameNegocio.Alterar(id, objTipoExame); return(Accepted(obj)); }
public async Task <IActionResult> Update([FromBody] TipoExame entity) { if (entity == null) { return(BadRequest()); } entity.DtAlteracao = DateTime.Now; await _service.UpdateAsync(entity); return(new NoContentResult()); }
public ActionResult Edit(TipoExame tipoExame) { if (ModelState.IsValid) { db.Entry(tipoExame).State = EntityState.Modified; db.SaveChanges(); db.Dispose(); return(RedirectToAction("Index")); } return(View(tipoExame)); }
public ActionResult Create(TipoExame tipoExame) { if (ModelState.IsValid) { db.TiposExames.Add(tipoExame); db.SaveChanges(); db.Dispose(); return(RedirectToAction("Index")); } return(View(tipoExame)); }
public void Add(TipoExame entity) { try { entity.TipoExameId = entity.TipoExameId <= Decimal.Zero ? _data.Select(s => s.TipoExameId).Max() + 1 : entity.TipoExameId; _data.Add(entity); } catch (System.Exception ex) { throw new RepositoryException(ex); } }
public void Remove(TipoExame entity) { try { _dbContext.TipoExames.Remove(entity); _dbContext.SaveChanges(); } catch (System.Exception ex) { throw new RepositoryException(ex); } }
public void Update(TipoExame entity) { try { Remove(Find(entity.TipoExameId)); Add(entity); } catch (System.Exception ex) { throw new RepositoryException(ex); } }
public IActionResult Post([FromBody] TipoExameInput input) { var obj = new TipoExame() { Nome = input.Nome }; var idTipoExame = _tipoExameNegocio.Inserir(obj); obj.Id = idTipoExame; return(CreatedAtRoute("TipoExameGetId", new { id = idTipoExame }, obj)); }
public void ComoAdministradorDoCadastroCorporativoQueroGravarUmTipoDeExame() { //Arrange ITiposDeExames tiposDeExames = new TiposDeExamesFake(); //Act TipoExame tipoExame = new TipoExame("1234", "teste", 100); var retorno = tiposDeExames.Gravar(tipoExame); //Assert Assert.IsTrue(retorno); }
public void Update(TipoExame entity) { try { DetachLocal(d => d.TipoExameId == entity.TipoExameId); _dbContext.TipoExames.Update(entity); _dbContext.SaveChanges(); } catch (System.Exception ex) { throw new RepositoryException(ex); } }
// GET: TipoExames/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TipoExame tipoExame = db.TipoExames.Find(id); if (tipoExame == null) { return(HttpNotFound()); } return(View(tipoExame)); }
public void ValidarCoberturaDePlanosSulAmerica() { //Arrange PlanoDeSaude planoDeSaude = new PlanoDeSaude(); planoDeSaude.CNPJ = "004.004.0004/00004-40"; TipoExame tipoExame = new TipoExame("Exame de Sangue"); Exame exame = new Exame(tipoExame, new System.DateTime(2015, 10, 10)); //Act var retorno = planoDeSaude.VerificarCobertura(exame); //Arrange Assert.IsTrue(retorno == true); }
public void ValidarCoberturaDePlanosDeBradesco() { //Arrange PlanoDeSaude planoDeSaude = new PlanoDeSaude(); planoDeSaude.CNPJ = "002.002.0002/00002-20"; TipoExame tipoExame = new TipoExame("Exame de Sangue"); Exame exame = new Exame(tipoExame, new System.DateTime(2015, 10, 10)); //Act var retorno = planoDeSaude.VerificarCobertura(exame); //Arrange Assert.IsTrue(retorno == false); }