public static NivelEN Convert(NivelDTO dto) { NivelEN newinstance = null; try { if (dto != null) { newinstance = new NivelEN(); newinstance.Id = dto.Id; newinstance.Numero = dto.Numero; newinstance.Puntuacion = dto.Puntuacion; if (dto.Item_oid != null) { ReciclaUAGenNHibernate.CAD.ReciclaUA.IItemCAD itemCAD = new ReciclaUAGenNHibernate.CAD.ReciclaUA.ItemCAD(); newinstance.Item = new System.Collections.Generic.List <ReciclaUAGenNHibernate.EN.ReciclaUA.ItemEN>(); foreach (int entry in dto.Item_oid) { newinstance.Item.Add(itemCAD.ReadOIDDefault(entry)); } } } } catch (Exception ex) { throw ex; } return(newinstance); }
public void Add(NivelDTO pergunta) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <Nivel, NivelDTO>(); }); IMapper iMapper = config.CreateMapper(); var destination = iMapper.Map <NivelDTO, Nivel>(pergunta); _repo.Add(destination); }
public JsonResult Editar(string descripcion, string catalogoId, string itemId) { string result = "duplicate"; switch (catalogoId) { case "m": if (!cliente.ObtenerCatalogoMaterias().Any(m => m.Descripcion.ToLower() == descripcion.ToLower())) { MateriaDTO materia = new MateriaDTO(); materia.Descripcion = descripcion; materia.Id = Int32.Parse(itemId); cliente.ActualizarMateria(materia); result = "success"; } break; case "p": if (!cliente.ObtenerCatalogoPeriodos().Any(m => m.Descripcion.ToLower() == descripcion.ToLower())) { PeriodoDTO periodo = new PeriodoDTO(); periodo.Descripcion = descripcion; periodo.Id = Int32.Parse(itemId); cliente.ActualizarPeriodo(periodo); result = "success"; } break; case "n": if (!cliente.ObtenerCatalogoNiveles().Any(m => m.Descripcion.ToLower() == descripcion.ToLower())) { NivelDTO nivel = new NivelDTO(); nivel.Descripcion = descripcion; nivel.Id = Int32.Parse(itemId); cliente.ActualizarNivel(nivel); result = "success"; } break; case "c": if (!cliente.ObtenerCatalogoCursosLectivos().Any(m => m.Descripcion.ToLower() == descripcion.ToLower())) { CursoLectivoDTO cursoLectivo = new CursoLectivoDTO(); cursoLectivo.Descripcion = descripcion; cursoLectivo.Id = Int32.Parse(itemId); cliente.ActualizarCursoLectivo(cursoLectivo); result = "success"; } break; } return(new JsonResult { Data = new { Result = result } }); }
public void ActualizarNivel(NivelDTO nivel) { var b = new NivelDAO(); if (nivel.Id > 0) { b.ActualizarNivel(nivel, true); } else { b.ActualizarNivel(nivel, false); } }
public ActionResult <NivelDTO> Post([FromBody] NivelDTO value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var nivel = new Nivel() { NomeNivel = value.NomeNivel }; var retorno = _nivelService.Salvar(nivel); return(Ok(_mapper.Map <NivelDTO>(retorno))); }
public void ActualizarNivel(NivelDTO nivel, bool editar) { using (BAPLNEntities entities = new BAPLNEntities()) { if (editar) { CAT_Nivel existente = entities.CAT_Nivel.FirstOrDefault(v => v.Id == nivel.Id); if (existente != null) { existente.Descripcion = nivel.Descripcion; entities.SaveChanges(); } } else { CAT_Nivel nuevo = new CAT_Nivel(); nuevo.Descripcion = nivel.Descripcion; nuevo.Activa = true; entities.CAT_Nivel.Add(nuevo); entities.SaveChanges(); } } }
public void EditarNivel(NivelDTO curso) { var b = new NivelDAO(); b.ActualizarNivel(curso, false); }
public void EditarNivel(NivelDTO nivel) { NivelDAL n = new NivelDAL(); n.EditarNivel(nivel); }
public void ActualizarNivel(NivelDTO nivel) { NivelDAL n = new NivelDAL(); n.ActualizarNivel(nivel); }
public void Update(NivelDTO pergunta) { throw new System.NotImplementedException(); }
public void Post([FromBody] NivelDTO value) { var categoria = _mapper.Map <Nivel>(value); _nivelAplication.Post(categoria); }
public HttpResponseMessage Modificar(int idNivel, [FromBody] NivelDTO dto) { // CAD, CEN, returnValue NivelRESTCAD nivelRESTCAD = null; NivelCEN nivelCEN = null; NivelDTOA returnValue = null; // HTTP response HttpResponseMessage response = null; string uri = null; try { SessionInitializeTransaction(); string token = ""; if (Request.Headers.Authorization != null) { token = Request.Headers.Authorization.ToString(); } int id = new UsuarioCEN().CheckToken(token); nivelRESTCAD = new NivelRESTCAD(session); nivelCEN = new NivelCEN(nivelRESTCAD); // Modify nivelCEN.Modificar(idNivel, dto.Numero , dto.Puntuacion ); // Return modified object returnValue = NivelAssembler.Convert(nivelRESTCAD.ReadOIDDefault(idNivel), session); SessionCommit(); } catch (Exception e) { SessionRollBack(); if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 404 - Not found if (returnValue == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } // Return 200 - OK else { response = this.Request.CreateResponse(HttpStatusCode.OK, returnValue); return(response); } }
public HttpResponseMessage Crear([FromBody] NivelDTO dto) { // CAD, CEN, returnValue, returnOID NivelRESTCAD nivelRESTCAD = null; NivelCEN nivelCEN = null; NivelDTOA returnValue = null; int returnOID = -1; // HTTP response HttpResponseMessage response = null; string uri = null; try { SessionInitializeTransaction(); string token = ""; if (Request.Headers.Authorization != null) { token = Request.Headers.Authorization.ToString(); } int id = new UsuarioCEN().CheckToken(token); nivelRESTCAD = new NivelRESTCAD(session); nivelCEN = new NivelCEN(nivelRESTCAD); // Create returnOID = nivelCEN.Crear( //Atributo Primitivo: p_numero dto.Numero, //Atributo Primitivo: p_puntuacion dto.Puntuacion); SessionCommit(); // Convert return returnValue = NivelAssembler.Convert(nivelRESTCAD.ReadOIDDefault(returnOID), session); } catch (Exception e) { SessionRollBack(); if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 201 - Created response = this.Request.CreateResponse(HttpStatusCode.Created, returnValue); // Location Header /* * Dictionary<string, object> routeValues = new Dictionary<string, object>(); * * // TODO: y rolPaths * routeValues.Add("id", returnOID); * * uri = Url.Link("GetOIDNivel", routeValues); * response.Headers.Location = new Uri(uri); */ return(response); }