public AgendaDto Alterar(AgendaDto agendaDto) { var agendasDoDia = _agendaServico.ObterAgendasPorDataConsulta(agendaDto.DataInicialConsulta); var agendaCadastrada = _agendaServico.ObterPorId(agendaDto.Id); if (agendaCadastrada == null) { throw new Exception("Agenda não encontrada"); } if (agendaDto.DataFimConsulta < agendaDto.DataInicialConsulta) { throw new Exception("A data final da consulta não pode ser menor que a data inicial"); } if (agendasDoDia != null && agendasDoDia.Any()) { if (agendasDoDia.FirstOrDefault(x => x.Id != agendaDto.Id && x.DataInicialConsulta.TimeOfDay >= agendaDto.DataInicialConsulta.TimeOfDay && x.DataFimConsulta.TimeOfDay <= agendaDto.DataFimConsulta.TimeOfDay) != null) { throw new Exception("O horário da consulta informado já possui agenda marcada"); } } agendaCadastrada.NomePaciente = agendaDto.NomePaciente; agendaCadastrada.DataNascimentoPaciente = agendaDto.DataNascimentoPaciente; agendaCadastrada.DataInicialConsulta = agendaDto.DataInicialConsulta; agendaCadastrada.DataFimConsulta = agendaDto.DataFimConsulta; agendaCadastrada.Observacoes = agendaDto.Observacoes; _agendaServico.Alterar(agendaCadastrada); return(agendaDto); }
IEnumerable <IAgenda> IAgendaContext.GetAll(int movieId) { _connection.SqlConnection.Open(); var cmd = new MySqlCommand("SELECT * FROM agenda WHERE MovieId=@MovieId", _connection.SqlConnection); cmd.Parameters.AddWithValue("@MovieId", movieId); var reader = cmd.ExecuteReader(); var agendaRecords = new List <IAgenda>(); while (reader.Read()) { var agenda = new AgendaDto { AgendaId = (int)reader["AgendaId"], MovieId = (int)reader["MovieId"], MovieName = reader["MovieName"]?.ToString(), MovieHallId = (int)reader["MovieHallId"], IsValid = (bool)reader["IsValid"], Time = DateTime.Parse(reader["Time"]?.ToString() ?? ""), Price = (double)reader["Price"] }; agendaRecords.Add(agenda); } return(agendaRecords); }
public async Task <IActionResult> Update([FromBody] AgendaDto agenda, int id) { var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var schedule = await _repo.GetSchedule(id); if (schedule == null) { return(NotFound(new { message = "Atividade não encontrada" })); } if (schedule.UserId != userId) { return(Forbid()); } agenda.Id = schedule.Id; agenda.UserId = schedule.UserId; await _repo.Update(agenda); if (await _uof.Commit()) { return(NoContent()); } throw new Exception("Houve um erro ao atualizar uma atividade!"); }
internal override DtoBase PopulateDto(OracleDataReader reader) { var agenda = new AgendaDto(); // if (!reader.IsDBNull(_ordAgeId)) { agenda.AgeId = reader.GetInt32(_ordAgeId); } // if (!reader.IsDBNull(_ordAgeHoraDesde)) { agenda.AgeHoraDesde = reader.GetDateTime(_ordAgeHoraDesde); } // if (!reader.IsDBNull(_ordAgeHoraHasta)) { agenda.AgeHoraHasta = reader.GetDateTime(_ordAgeHoraHasta); } // if (!reader.IsDBNull(_ordAgeProId)) { agenda.AgeProId = reader.GetInt32(_ordAgeProId); } // if (!reader.IsDBNull(_ordAgeDiaId)) { agenda.AgeDiaId = reader.GetInt32(_ordAgeDiaId); } // IsNew agenda.IsNew = false; return(agenda); }
public async Task <IActionResult> Put(AgendaDto agendaDto) { try { var salvamentoService = await _service.SalvarAlteracoes(agendaDto, "put"); return(Created($"/api/agenda/{agendaDto.Id}", _mapper.Map <AgendaDto>(salvamentoService))); } catch (BusinessException e) { switch (e.Message) { case "empresainvalida": return(Ok("empresainvalida")); case "momento": return(Ok("momento")); case "dataCerta": return(Ok("dataCerta")); case "horarioImproprio": return(Ok("horarioImproprio")); case "valido": return(Ok("valido")); case "-": return(NotFound()); default: return(Ok(e.Message)); } } catch (DbConcurrencyException e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados Falhou, pelo motivo: {0}" + e)); } }
public Work(AgendaDto agenda) { this.Local = agenda.Local; this.Reschedule = agenda.Reschedule; this.Title = agenda.Title; this.Description = agenda.Description; this.UserId = agenda.UserId; this.DateWork = agenda.DateWork; }
public Project(AgendaDto agenda) { this.Local = agenda.Local; this.Reschedule = agenda.Reschedule; this.Title = agenda.Title; this.Description = agenda.Description; this.UserId = agenda.UserId; this.StartProject = agenda.StartProject; this.EndProject = agenda.EndProject; }
public Reunion(AgendaDto agenda) { this.Local = agenda.Local; this.Reschedule = agenda.Reschedule; this.Title = agenda.Title; this.Description = agenda.Description; this.HourEnd = agenda.HourEnd; this.HourStart = agenda.HourStart; this.DateReunion = agenda.DateReunion; this.UserId = agenda.UserId; }
public AgendaDto Deletar(AgendaDto agendaDto) { var agendaCadastrada = _agendaServico.ObterPorId(agendaDto.Id); if (agendaCadastrada == null) { throw new Exception("Agenda não encontrada"); } _agendaServico.Deletar(agendaCadastrada); return(agendaDto); }
public Agenda CreateAgenda(AgendaDto agenda) { var entity = new Agenda { AgendaId = agenda.AgendaId, MedicoId = agenda.MedicoId, Fecha = agenda.Fecha, }; _repository.Add <Agenda>(entity); return(entity); }
public ActionResult Save(AgendaDto model) { if (ModelState.IsValid) { var Agenda = new Agenda(); _Agenda.Save(model); return(RedirectToAction("List")); } else { return(RedirectToAction("Create", model)); } }
public ActionResult Post([FromBody] AgendaModel agendaModel) { if (ModelState.IsValid) { string format = "yyyy-MM-dd HH:mm"; CultureInfo provider = CultureInfo.InvariantCulture; DateTime dataInit = DateTime.ParseExact(agendaModel.DataInit, format, provider); DateTime dataEnd = DateTime.ParseExact(agendaModel.DataEnd, format, provider); int result = DateTime.Compare(dataEnd, dataInit); if (result < 0 || result == 0) { return(BadRequest("data invalida")); } else { AgendaDto agendaDto = new AgendaDto() { Id = 0, Sala = agendaModel.Sala, Responsavel = agendaModel.Responsavel, Tema = agendaModel.Tema, DataInit = dataInit, DataEnd = dataEnd }; try { var resultado = applicationServiceAgenda.Add(agendaDto); if (resultado) { return(Ok(applicationServiceAgenda.GetAll().Where(x => x.Sala == agendaDto.Sala))); } else { return(BadRequest("data invalida")); } } catch (Exception ex) { return(BadRequest(ex)); } } } else { return(BadRequest(ModelState)); } }
public ActionResult Alterar(AgendaDto agendaDto) { try { var agenda = _agendaAplicacao.Alterar(agendaDto); _uow.Commit(); return(Ok(agenda)); } catch (Exception ex) { _uow.RollBack(); return(BadRequest($"Erro: {ex.Message}")); } }
public AgendaDto MapperEntityToDto(Agenda agenda) { var agendaDto = new AgendaDto() { Id = agenda.Id, Sala = agenda.Sala, Responsavel = agenda.Responsavel, Tema = agenda.Tema, DataInit = agenda.DataInit, DataEnd = agenda.DataEnd }; return(agendaDto); }
public Agenda MapperDtoToEntity(AgendaDto agendaDto) { var agenda = new Agenda() { Id = agendaDto.Id.Value, Sala = agendaDto.Sala, Responsavel = agendaDto.Responsavel, Tema = agendaDto.Tema, DataInit = agendaDto.DataInit, DataEnd = agendaDto.DataEnd }; return(agenda); }
public AgendaDto MapperEntityToDto(Agenda agenda) { var agendaDto = new AgendaDto() { Id = agenda.Id, DataFimConsulta = agenda.DataFimConsulta, DataInicialConsulta = agenda.DataInicialConsulta, DataNascimentoPaciente = agenda.DataNascimentoPaciente, NomePaciente = agenda.NomePaciente, Observacoes = agenda.Observacoes }; return(agendaDto); }
public Agenda MapperDtoToEntity(AgendaDto agendaDto) { var agenda = new Agenda() { Id = agendaDto.Id, DataFimConsulta = agendaDto.DataFimConsulta, DataInicialConsulta = agendaDto.DataInicialConsulta, DataNascimentoPaciente = agendaDto.DataNascimentoPaciente, NomePaciente = agendaDto.NomePaciente, Observacoes = agendaDto.Observacoes }; return(agenda); }
public async Task <IActionResult> Delete(AgendaDto dto) { var result = new HttpResult <AgendaDto>(this._logger); try { await this._app.Remove(dto); return(result.ReturnCustomResponse(this._app, dto)); } catch (Exception ex) { return(result.ReturnCustomException(ex, "Calemas.Erp - Agenda", dto)); } }
public async Task <IActionResult> Store([FromBody] AgendaDto agenda) { var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); agenda.UserId = userId; await _repo.Add(agenda); if (await _uof.Commit()) { return(StatusCode(201, new { message = "Atividade criada com sucesso!" })); } throw new Exception("Houve um erro interno ao salvar uma atividade"); }
public IActionResult PostAgenda([FromBody] Agenda entity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = _userManager.GetUserId(this.User); entity.UserId = user; Agenda agenda = _agendaService.Create(entity); AgendaDto agendaDto = _mapper.Map <AgendaDto>(agenda); return(Ok(agendaDto)); }
public async Task Update(AgendaDto agenda) { var work = await _context.Works .Where(x => x.Id == agenda.Id) .FirstOrDefaultAsync(); if (work != null) { work.Local = agenda.Local; work.Reschedule = agenda.Reschedule; work.Title = agenda.Title; work.Description = agenda.Description; work.UserId = agenda.UserId; work.DateWork = agenda.DateWork; } var project = await _context.Projects .Where(x => x.Id == agenda.Id) .FirstOrDefaultAsync(); if (project != null) { project.Local = agenda.Local; project.Reschedule = agenda.Reschedule; project.Title = agenda.Title; project.Description = agenda.Description; project.UserId = agenda.UserId; project.StartProject = agenda.StartProject; project.EndProject = agenda.EndProject; } var reunion = await _context.Reunions .Where(x => x.Id == agenda.Id) .FirstOrDefaultAsync(); if (reunion != null) { reunion.Local = agenda.Local; reunion.Reschedule = agenda.Reschedule; reunion.Title = agenda.Title; reunion.Description = agenda.Description; reunion.HourEnd = agenda.HourEnd; reunion.HourStart = agenda.HourStart; reunion.DateReunion = agenda.DateReunion; reunion.UserId = agenda.UserId; } }
public ActionResult Deletar(int id) { try { var agendaDto = new AgendaDto() { Id = id }; var agenda = _agendaAplicacao.Deletar(agendaDto); _uow.Commit(); return(Ok(agenda)); } catch (Exception ex) { _uow.RollBack(); return(BadRequest($"Erro: {ex.Message}")); } }
public AgendaDto Incluir(AgendaDto agendaDto) { var agenda = _mapperAgenda.MapperDtoToEntity(agendaDto); var agendasDoDia = _agendaServico.ObterAgendasPorDataConsulta(agenda.DataInicialConsulta); if (agenda.DataFimConsulta < agenda.DataInicialConsulta) { throw new Exception("A data final da consulta não pode ser menor que a data inicial"); } if (agendasDoDia != null && agendasDoDia.Any()) { if (agendasDoDia.FirstOrDefault(x => x.DataInicialConsulta.TimeOfDay >= agenda.DataInicialConsulta.TimeOfDay && x.DataFimConsulta.TimeOfDay <= agenda.DataFimConsulta.TimeOfDay) != null) { throw new Exception("O horário da consulta informado já possui agenda marcada"); } } _agendaServico.Incluir(agenda); return(agendaDto); }
public bool Add(AgendaDto agendaDto) { var result = serviceAgenda.GetAll(); var agendas = mapperAgenda.MapperListAgendaDto(result).Where(x => x.Sala == agendaDto.Sala); bool valido = true; foreach (AgendaDto item in agendas) { int resultInit = DateTime.Compare(agendaDto.DataInit, item.DataInit); int resultEnd = DateTime.Compare(agendaDto.DataInit, item.DataEnd); if ((resultInit == 0) || (resultInit > 0 && resultEnd < 0)) { valido = false; } resultInit = DateTime.Compare(agendaDto.DataEnd, item.DataInit); resultEnd = DateTime.Compare(agendaDto.DataEnd, item.DataEnd); if (resultEnd == 0 || (resultInit > 0 && resultEnd < 0)) { valido = false; } resultInit = DateTime.Compare(agendaDto.DataInit, item.DataInit); resultEnd = DateTime.Compare(agendaDto.DataEnd, item.DataEnd); if (resultInit < 0 && resultEnd > 0) { valido = false; } } if (valido) { var agenda = mapperAgenda.MapperDtoToEntity(agendaDto); serviceAgenda.Add(agenda); } return(valido); }
public async Task Add(AgendaDto agenda) { Schedule schedule; if (agenda.Tipo == "Reunion") { schedule = new Reunion(agenda); await _context.Schedules.AddAsync(schedule); } else if (agenda.Tipo == "Work") { schedule = new Work(agenda); await _context.Schedules.AddAsync(schedule); } else if (agenda.Tipo == "Project") { schedule = new Project(agenda); await _context.Schedules.AddAsync(schedule); } }
public JsonResult RecuperarEventoAgenda(int id) { var evento = _agendaService.GetById(id); AgendaDto agendaDto = new AgendaDto { Id = evento.Id, CodigoCliente = evento.CodigoCliente, CodigoEspecialidade = evento.CodigoEspecialidade, CodigoProfissional = evento.CodigoProfissional, DataInicioEvento = evento.DataInicio, DataFimEvento = evento.DataFim, DescricaoEspecialidade = evento.Especialidade.Descricao, NomeCliente = evento.Cliente.Nome, NomeProfissional = evento.Profissional.Nome, CodigoServico = evento.Servico != null ? evento.CodigoServico : null, DescricaoServico = evento.Servico != null ? evento.Servico.Descricao : "", Procedimento = evento.Procedimento, Telefones = (evento.Cliente.TelefoneCelular ?? "") + ((evento.Cliente.TelefoneFixo == null || evento.Cliente.TelefoneFixo == string.Empty ? "" : "/") + evento.Cliente.TelefoneFixo ?? "") }; return(Json(agendaDto, JsonRequestBehavior.AllowGet)); }
public ActionResult <Agenda> Post(AgendaDto paciente) { return(StatusCode(201, _service.CreateAgenda(paciente))); }
public void Update(AgendaDto agendaDto) { var agenda = mapperAgenda.MapperDtoToEntity(agendaDto); serviceAgenda.Update(agenda); }
private void ObtenerDatosPantalla(ProfesionalDto profesional) { #region Persona ----------------------------------------- string aux; profesional.PsnNroDcto = txtDocumento.Value; if (!string.IsNullOrEmpty(txtNombre.Value)) { aux = txtNombre.Value; profesional.PsnNombre = aux.ToUpper(); } if (!string.IsNullOrEmpty(txtApellido.Value)) { aux = txtApellido.Value; profesional.PsnApellido = aux.ToUpper(); } profesional.PsnFechaNac = txtFecNac.Value; profesional.PsnTelefono = txtTel.Value; if (!string.IsNullOrEmpty(txtDire.Value)) { aux = txtDire.Value; profesional.PsnDomicilio = aux.ToUpper(); } if (!string.IsNullOrEmpty(txtMail.Value)) { aux = txtMail.Value; profesional.PsnEmail = aux.ToUpper(); } if (rbM.Checked) { profesional.PsnSexo = "M"; } else if (rbF.Checked) { profesional.PsnSexo = "F"; } profesional.ProActivo = "S"; #endregion #region Matriculas -------------------------------------- if (ViewState["DadaTableMat"] != null) { var dtMat = (DataTable)ViewState["DadaTableMat"]; var listaMatricula = new List <ProfesionalMatriculaDto>(); foreach (DataRow dtRow in dtMat.Rows) { var matricula = new ProfesionalMatriculaDto(); if (!DBNull.Value.Equals(dtRow[0])) { matricula.PmtId = Convert.ToInt32(dtRow[0].ToString()); } matricula.PmtMttId = Convert.ToInt32(dtRow[1].ToString()); if (!DBNull.Value.Equals(dtRow["PMTNRO"])) { matricula.PmtNro = dtRow["PMTNRO"].ToString(); } listaMatricula.Add(matricula); } profesional.ProListMatriculas = listaMatricula; } #endregion #region Especialidades ---------------------------------- profesional.ProListEspecialidades = listaEspecialidades; #endregion #region Agenda ------------------------------------------ if (ViewState["DataTableAge"] != null) { var dtAge = (DataTable)ViewState["DataTableAge"]; var listaAgenda = new List <AgendaDto>(); foreach (DataRow dtRow in dtAge.Rows) { var agenda = new AgendaDto(); if (!DBNull.Value.Equals(dtRow[0])) { agenda.AgeId = Convert.ToInt32(dtRow[0].ToString()); } agenda.AgeDiaId = Convert.ToInt32(dtRow[1].ToString()); // Descripcion del tipo de dia = dtRow[2].ToString() agenda.AgeHoraDesde = dtRow[3].ToString(); agenda.AgeHoraHasta = dtRow[4].ToString(); listaAgenda.Add(agenda); } profesional.ProListAgenda = listaAgenda; } #endregion var varEstado = Request.QueryString["e"]; if (varEstado == "B") { if (lblProId != null) { profesional.ProId = Convert.ToInt32(lblProId.Text); } if (lblPsnId != null) { profesional.PsnId = Convert.ToInt32(lblPsnId.Text); } var opcionSeleccionada = ddlEstado.SelectedItem.ToString(); if (opcionSeleccionada == "NO") { profesional.ProActivo = "N"; } else { profesional.ProActivo = "S"; } } }
public async Task <Agenda> SalvarAlteracoes(AgendaDto agendaDto, string verbo) { agendaDto.DataHora = agendaDto.DataHora.AddHours(-3); //string data = agendaDto.DataHora.Month + "/" + agendaDto.DataHora.Day + "/" + agendaDto.DataHora.Year + " " // + agendaDto.DataHora.TimeOfDay; //agendaDto.DataHora = Convert.ToDateTime(data); //Implementar no Service TimeSpan semDuracao = new TimeSpan(0, 0, 0); var agendamentoModel = _mapper.Map <Agenda>(agendaDto); var agendamento = await _repo.ObterAgenda(agendamentoModel); var agenda = agendamento.FirstOrDefault(); var admins = await _repo.ObterTodosUsuariosAsync(); var empresa = admins.Where(x => x.Id == agendaDto.UsuarioId || x.Id == agendaDto.AdmId).Select(x => x.Company).FirstOrDefault(); var temEmpresa = await _repo.TemEmpresa(empresa); if (agendamento == null && verbo.Equals("put")) { throw new BusinessException("-"); } var clientesAgendados = await _repo.ObterClientesAgendadosMesmaDataAsync(agendamentoModel); var horariosAtendimento = await _repo.ObterHorariosAtendimento(agendamentoModel); var horarioInicioFim = await _repo.ObterInicioFim(agendamentoModel); var agendamentoIndisponivel = await _repo.VerificarIndisponibilidade(agendamentoModel); TimeSpan horarioAgendado = TimeSpan.Parse(agendaDto.DataHora.ToString("HH:mm:ss")); if (temEmpresa) { if (agendamentoIndisponivel.ToString() == "") { if (agendamentoModel.DataHora > DateTime.Now) { if (clientesAgendados.Length <= 0) { if (horariosAtendimento.Count > 1 && horariosAtendimento[0] != semDuracao) { if (horariosAtendimento.Contains(horarioAgendado)) { if (verbo.Equals("put")) { try { _mapper.Map(agendaDto, agenda); _repo.Update(agenda); await _repo.SaveChangesAsync(); return(agendamentoModel); } catch (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } } else if (verbo.Equals("post")) { try { _repo.Add(agendamentoModel); await _repo.SaveChangesAsync(); return(agendamentoModel); } catch (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } } } else { throw new BusinessException("valido"); } } // deixar horarioInicioFim.Count == 1 else if (horarioInicioFim.Count == 1 && horarioInicioFim[0] == semDuracao) { throw new BusinessException("horarioImproprio"); } else { if (verbo.Equals("put")) { try { _mapper.Map(agendaDto, agenda); _repo.Update(agenda); await _repo.SaveChangesAsync(); return(agendamentoModel); } catch (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } } else if (verbo.Equals("post")) { try { _repo.Add(agendamentoModel); await _repo.SaveChangesAsync(); return(agendamentoModel); } catch (DbConcurrencyException e) { throw new DbConcurrencyException(e.Message); } } } } else { throw new BusinessException("dataCerta"); } } else { throw new BusinessException("momento"); } } else { throw new BusinessException(agendamentoIndisponivel.ToString()); } } else { throw new BusinessException("empresainvalida"); } return(agendamentoModel); }