public OBRA_MSTR_DTO GetObraMstrRepository(int id) { OBRA_MSTR_DTO getObraMstrDto = new OBRA_MSTR_DTO(); if (ReferenceEquals(context, null)) { context = new CalfuEntities(); } try { _obraMstr = new OBRA_MSTR(); _obraMstr = context.OBRA_MSTR.Where(x => x.OBRA_ID.Equals(id)).FirstOrDefault(); getObraMstrDto.OBRA_ID = _obraMstr.OBRA_ID; getObraMstrDto.ALIAS = _obraMstr.ALIAS; getObraMstrDto.ANCHO = _obraMstr.ANCHO; getObraMstrDto.DESCRIPCION = _obraMstr.DESCRIPCION; getObraMstrDto.FILE_NAME = _obraMstr.FILE_NAME; getObraMstrDto.ME_GUSTA = _obraMstr.ME_GUSTA; getObraMstrDto.NO_ME_GUSTA = _obraMstr.NO_ME_GUSTA; getObraMstrDto.TIPO_OBRA_ID = _obraMstr.TIPO_OBRA_ID; getObraMstrDto.FLAG_VIGENTE = _obraMstr.FLAG_VIGENTE; //OBRA_MSTR_DTO getObraMstrDto = context.OBRA_MSTR.Where(x => x.OBRA_ID.Equals(id)).ProjectTo<OBRA_MSTR_DTO>().FirstOrDefault(); return(getObraMstrDto); } catch (Exception ex) { return(null); } }
public bool UpdateObraMstr(OBRA_MSTR_DTO dto) { try { if (ReferenceEquals(context, null)) { context = new CalfuEntities(); } OBRA_MSTR obraMstr = context.OBRA_MSTR.Where(x => x.OBRA_ID.Equals(dto.OBRA_ID)).SingleOrDefault(); if (!ReferenceEquals(null, obraMstr)) { obraMstr.ALIAS = dto.ALIAS; obraMstr.ANCHO = dto.ANCHO; obraMstr.DESCRIPCION = dto.DESCRIPCION; obraMstr.FILE_NAME = dto.FILE_NAME; obraMstr.ME_GUSTA = dto.ME_GUSTA; obraMstr.NO_ME_GUSTA = dto.NO_ME_GUSTA; obraMstr.TIPO_OBRA_ID = dto.TIPO_OBRA_ID; context.SaveChanges(); } context.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public IHttpActionResult UpdateObra(OBRA_MSTR_DTO obraDto) { string retorno = ""; _obraMstrRepository = new OBRA_MSTR_Repository(); retorno = _obraMstrRepository.UpdateObraMstr(obraDto) ? "Exito" : "Error"; return(Ok(retorno)); }
public IHttpActionResult AddObra(OBRA_MSTR_DTO obraDto) { string retorno = ""; _obraMstrRepository = new OBRA_MSTR_Repository(); if (_obraMstrRepository.ExistObraMstrRepository(obraDto.OBRA_ID)) { retorno = _obraMstrRepository.UpdateObraMstr(obraDto) ? "Exito" : "Error"; } else { retorno = _obraMstrRepository.CreateObraMstr(obraDto) ? "Exito" : "Error"; } return(Ok(retorno)); }
public bool CreateObraMstr(OBRA_MSTR_DTO dto) { try { var _obraMstr = new OBRA_MSTR(); _obraMstr.ALIAS = dto.ALIAS; _obraMstr.ANCHO = dto.ANCHO; _obraMstr.DESCRIPCION = dto.DESCRIPCION; _obraMstr.FILE_NAME = dto.FILE_NAME; _obraMstr.ME_GUSTA = dto.ME_GUSTA; _obraMstr.NO_ME_GUSTA = dto.NO_ME_GUSTA; _obraMstr.TIPO_OBRA_ID = dto.TIPO_OBRA_ID; context.OBRA_MSTR.Add(_obraMstr); context.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }