Esempio n. 1
0
        public ActionResult Atualizar(LaboratorioDto model)
        {
            var LaboratorioDto = _serviceLaboratorio.Atualizar(Request.Cookies[FormsAuthentication.FormsCookieName].Value, model);

            if (LaboratorioDto)
            {
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Esempio n. 2
0
 public IHttpActionResult Cadastrar(LaboratorioDto laboratorioDto)
 {
     try
     {
         serviceLatoratorio.Cadastrar(laboratorioDto);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
 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));
     }
 }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        public ActionResult Cadastrar()
        {
            var model = new LaboratorioDto();

            return(View(model));
        }