public ActionResult Atualizar(LaboratorioDto model) { var LaboratorioDto = _serviceLaboratorio.Atualizar(Request.Cookies[FormsAuthentication.FormsCookieName].Value, model); if (LaboratorioDto) { return(RedirectToAction("Index")); } return(View(model)); }
public IHttpActionResult Cadastrar(LaboratorioDto laboratorioDto) { try { serviceLatoratorio.Cadastrar(laboratorioDto); return(Ok()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void Cadastrar(LaboratorioDto laboratorioDto) { if (String.IsNullOrEmpty(laboratorioDto.Descricao)) { throw new Exception("É necessário uma descrição."); } var laboratorio = Mapper.Map <LaboratorioDto, Laboratorio>(laboratorioDto); contexo.Laboratorios.Add(laboratorio); contexo.SaveChanges(); }
public IHttpActionResult Atualizar(LaboratorioDto laboratorioDto) { try { serviceLatoratorio.Atualizar(laboratorioDto); return(Ok()); } catch (ObjectNotFoundException e) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, e.Message))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void Atualizar(LaboratorioDto laboratorioDto) { var laboratorio = contexo.Laboratorios.Where(x => x.Id == laboratorioDto.Id).FirstOrDefault(); if (laboratorio == null) { throw new ObjectNotFoundException("Disciplina não encontrada."); } laboratorio.Descricao = laboratorioDto.Descricao; laboratorio.NumeroSala = laboratorioDto.NumeroSala; laboratorio.Bloco = laboratorioDto.Bloco; laboratorio.QtdMaquinas = laboratorio.QtdMaquinas; contexo.Laboratorios.AddOrUpdate(laboratorio); contexo.SaveChanges(); }
public bool Atualizar(string token, LaboratorioDto laboratorio) { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:54438/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("Authorization", token); var response = client.PutAsJsonAsync("laboratorio", laboratorio).Result; if (response.IsSuccessStatusCode) { return(true); } return(false); } }
public ActionResult Cadastrar() { var model = new LaboratorioDto(); return(View(model)); }