public async Task <IActionResult> Adicionar(AgendamentoModel model) { RetornoDTO iRetorno = new RetornoDTO(); try { GerarTokenParaModel(Request.Headers); if (model == null) { return(BadRequest(MazzaFC.Dominio.Resources.Global._ModelInvalido)); } var _model = new MazzaFC.Dominio.Entidades.Agendamento(); _model.Salvar(model.PacienteId, model.MedicoId, model.AgendamentoDataHora, model.AgendamentoComentario); _model.ValidarEntidade(); _servicoDeAplicacaoAgendamento.Adicionar(_model); iRetorno.Sucesso(MazzaFC.Dominio.Resources.Global._OperacaoSucesso, _model.MedicoId); return(Ok(iRetorno)); } catch (Exception ex) { return(BadRequest(ex)); } }
public async Task <IActionResult> Excluir(AgendamentoModel model) { RetornoDTO iRetorno = new RetornoDTO(); try { GerarTokenParaModel(Request.Headers); var _model = _servicoDeAplicacaoAgendamento.ObterPorID(model.AgendamentoId.GetValueOrDefault()); if (_model == null) { return(BadRequest(MazzaFC.Dominio.Resources.Global._ModelInvalido)); } _model.Excluir(); _servicoDeAplicacaoAgendamento.Editar(_model); iRetorno.Sucesso(MazzaFC.Dominio.Resources.Global._OperacaoSucesso, _model.MedicoId); return(Ok(iRetorno)); } catch (Exception ex) { return(BadRequest(ex)); } }
public ActionResult DeleteConfirmed(int id) { AgendamentoModel agendamentoModel = db.AgendamentoModels.Find(id); db.AgendamentoModels.Remove(agendamentoModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Put(int id, [FromBody] AgendamentoModel model) { var agendamentoAnterior = _context.AgendamentoTable.SingleOrDefault(a => a.Id == id); agendamentoAnterior.Medico = model.Medico; agendamentoAnterior.DataHoraConsulta = model.DataHoraConsulta; _context.AgendamentoTable.Update(agendamentoAnterior); _context.SaveChanges(); }
public async Task <HttpStatusCode> UpdateAgendamentoAsync(AgendamentoModel model) { HttpResponseMessage response = await client.PutAsync( $"{URL}/{model.Agendamento_Id}", new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); return(response.StatusCode); }
public ActionResult Edit([Bind(Include = "id,dataEntrega,usuarioEntrega,enderecoEntrega,animal")] AgendamentoModel agendamentoModel) { if (ModelState.IsValid) { db.Entry(agendamentoModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(agendamentoModel)); }
// GET: Agendamento/Create/5 public ActionResult Create(string cnpj) { if (cnpj == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AgendamentoModel model = new AgendamentoModel(); model.ong = db.OngModels.First(a => a.cnpj == cnpj); return(View(model)); }
public async Task <IActionResult> UpdateAgendamento(AgendamentoModel model) { if (!ModelState.IsValid) { throw new Exception("Propriedades Inválidas"); } model.DiaSemana_Id = (int)model.DataAgendamento.GetValueOrDefault().DayOfWeek + 1; await _agendamentoService.UpdateAgendamentoAsync(model); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "id,dataEntrega,usuarioEntrega,enderecoEntrega,animal")] AgendamentoModel agendamentoModel, string cnpj) { agendamentoModel.ong = db.OngModels.First(a => a.cnpj == cnpj); agendamentoModel.usuario = db.UsuarioModels.First(); if (ModelState.IsValid) { db.AgendamentoModels.Add(agendamentoModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(agendamentoModel)); }
public IActionResult UpdateAgendamento(int agendamentoId, [FromBody] AgendamentoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var agendamento = _mapper.Map <Agendamento>(model); _agendamentoRepository.UpdateAgendamento(agendamento); return(Ok(model)); }
public IActionResult CreateAgendamento([FromBody] AgendamentoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var agendamento = _mapper.Map <Agendamento>(model); model.Agendamento_Id = _agendamentoRepository.CreateAgendamento(agendamento); return(Ok(model)); }
// GET: Agendamento/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AgendamentoModel agendamentoModel = db.AgendamentoModels.Find(id); if (agendamentoModel == null) { return(HttpNotFound()); } return(View(agendamentoModel)); }
public IActionResult UpdateAgendamento(int agendamentoId, [FromBody] AgendamentoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var agendamento = new Agendamento { AgendamentoId = model.Agendamento_Id, AgendamentoDescricao = model.Agendamento_Descricao, DataAgendamento = model.DataAgendamento, HorarioId = model.Horario_Id, DiaSemanaId = model.DiaSemana_Id }; _agendamentoRepository.UpdateCargo(agendamento); return(Ok(model)); }
public async Task <IActionResult> CreateAgendamento(int?clienteId) { ViewBag.ClientesList = await GetClientesListAsync(); ViewBag.EstabelecimentosList = await GetEstabelecimentosListAsync(); if (clienteId.HasValue) { var agendamento = new AgendamentoModel { Cliente_Id = clienteId.GetValueOrDefault() }; return(View(agendamento)); } else { return(View()); } }
public async Task <IActionResult> Confirm([FromBody] AgendamentoModel agendamento) { var agendaRepository = new AgendaRepository(_context); var userRepository = new UserRepository(_context); var authenticadedUser = ((ClaimsIdentity)User.Identity).Claims.FirstOrDefault()?.Value; var user = await userRepository.GetUserFromEmailOrOauthID(authenticadedUser); if (user == null) { return(NotFound("Usuário não encontrado")); } if (agendaRepository.IncludeAgendamento(user, agendamento)) { return(Ok()); } return(NotFound()); }
public async Task <AgendamentoModel> CreateAgendamentoAsync(AgendamentoModel model) { var agendamento = new AgendamentoModel(); HttpResponseMessage response = await client.PostAsync( URL, new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { using (var respostaStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) { return(JsonConvert.DeserializeObject <AgendamentoModel>( await new StreamReader(respostaStream). ReadToEndAsync().ConfigureAwait(false))); } } return(agendamento); }
public IActionResult CreateAgendamento([FromBody] AgendamentoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var agendamento = new Agendamento { AgendamentoDescricao = model.Agendamento_Descricao, ClienteId = model.Cliente_Id, EstabelecimentoId = model.Estabelecimento_Id, DataAgendamento = model.DataAgendamento, HorarioId = model.Horario_Id, DiaSemanaId = model.DiaSemana_Id }; var newAgendamento = _agendamentoRepository.CreateAgendamento(agendamento); model.Agendamento_Id = newAgendamento.AgendamentoId; return(Ok(model)); }
public bool IncludeAgendamento(User user, AgendamentoModel agendamento) { try { var dateSchedule = DateTime.Parse(agendamento.DateSchedule); var agendaApp = new AgendaAppointment { UserID = user.ID, AgendaScheduleID = agendamento.AgendaScheduleID, DateSchedule = GetCleanDateTime(dateSchedule), BeginTime = ConvertTimeToMinutes(agendamento.BeginTime), EndTime = ConvertTimeToMinutes(agendamento.EndTime) }; Context.AgendaAppointments.Add(agendaApp); Context.SaveChanges(); return(true); } catch { return(false); } }
public async Task <IActionResult> DeleteAgendamento(AgendamentoModel agendamento) { await _agendamentoService.DeleteAgendamentoAsync((int)agendamento.Agendamento_Id); return(RedirectToAction("Index")); }
public void Post([FromBody] AgendamentoModel model) { _context.AgendamentoTable.Add(model); _context.SaveChanges(); }