public void AddAuthorizedPerson(ref OperationResult pobjOperationResult, authorizedpersonDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; string NewId = "(No generado)"; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); authorizedperson objEntity = authorizedpersonAssembler.ToEntity(pobjDtoEntity); objEntity.d_InsertDate = DateTime.Now; objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]); // Autogeneramos el Pk de la tabla int intNodeId = int.Parse(ClientSession[0]); NewId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 100), "XX");; objEntity.v_AuthorizedPersonId = NewId; dbContext.AddToauthorizedperson(objEntity); dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "PERSONAS AUTORIZADAS", "v_AuthorizedPersonId=" + NewId.ToString(), Success.Ok, null); return; } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "PERSONAS AUTORIZADAS", "v_AuthorizedPersonId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }
/// <summary> /// Converts this instance of <see cref="authorizedperson"/> to an instance of <see cref="authorizedpersonDto"/>. /// </summary> /// <param name="entity"><see cref="authorizedperson"/> to convert.</param> public static authorizedpersonDto ToDTO(this authorizedperson entity) { if (entity == null) { return(null); } var dto = new authorizedpersonDto(); dto.v_AuthorizedPersonId = entity.v_AuthorizedPersonId; dto.v_FirstName = entity.v_FirstName; dto.v_FirstLastName = entity.v_FirstLastName; dto.v_SecondLastName = entity.v_SecondLastName; dto.i_DocTypeId = entity.i_DocTypeId; dto.v_DocTypeName = entity.v_DocTypeName; dto.v_DocNumber = entity.v_DocNumber; dto.i_SexTypeId = entity.i_SexTypeId; dto.v_SexTypeName = entity.v_SexTypeName; dto.d_BirthDate = entity.d_BirthDate; dto.v_OccupationName = entity.v_OccupationName; dto.v_OrganitationName = entity.v_OrganitationName; dto.d_EntryToMedicalCenter = entity.d_EntryToMedicalCenter; dto.v_ProtocolId = entity.v_ProtocolId; dto.v_ProtocolName = entity.v_ProtocolName; dto.i_InsertUserId = entity.i_InsertUserId; dto.d_InsertDate = entity.d_InsertDate; dto.i_UpdateUserId = entity.i_UpdateUserId; dto.d_UpdateDate = entity.d_UpdateDate; entity.OnDTO(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="authorizedpersonDto"/> to an instance of <see cref="authorizedperson"/>. /// </summary> /// <param name="dto"><see cref="authorizedpersonDto"/> to convert.</param> public static authorizedperson ToEntity(this authorizedpersonDto dto) { if (dto == null) { return(null); } var entity = new authorizedperson(); entity.v_AuthorizedPersonId = dto.v_AuthorizedPersonId; entity.v_FirstName = dto.v_FirstName; entity.v_FirstLastName = dto.v_FirstLastName; entity.v_SecondLastName = dto.v_SecondLastName; entity.i_DocTypeId = dto.i_DocTypeId; entity.v_DocTypeName = dto.v_DocTypeName; entity.v_DocNumber = dto.v_DocNumber; entity.i_SexTypeId = dto.i_SexTypeId; entity.v_SexTypeName = dto.v_SexTypeName; entity.d_BirthDate = dto.d_BirthDate; entity.v_OccupationName = dto.v_OccupationName; entity.v_OrganitationName = dto.v_OrganitationName; entity.d_EntryToMedicalCenter = dto.d_EntryToMedicalCenter; entity.v_ProtocolId = dto.v_ProtocolId; entity.v_ProtocolName = dto.v_ProtocolName; entity.i_InsertUserId = dto.i_InsertUserId; entity.d_InsertDate = dto.d_InsertDate; entity.i_UpdateUserId = dto.i_UpdateUserId; entity.d_UpdateDate = dto.d_UpdateDate; dto.OnEntity(entity); return(entity); }
//public List<authorizedpersonDto> GetAuthorizedPersonAccess(ref OperationResult pobjOperationResult, string pstrNameOrOrganitation) //{ // //mon.IsActive = true; // try // { // SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); // authorizedpersonDto objDtoEntity = null; // var objEntity = (from A in dbContext.authorizedperson // where ((A.v_FirstName + " " + A.v_FirstLastName + " " + A.v_SecondLastName).Contains(pstrNameOrOrganitation)) || A.v_OrganitationName.Contains(pstrNameOrOrganitation) // select A); // List<AuthorizedPersonList> objData = objEntity.ToList(); // pobjOperationResult.Success = 1; // return objData; // pobjOperationResult.Success = 1; // return objDtoEntity; // } // catch (Exception ex) // { // pobjOperationResult.Success = 0; // pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // return null; // } //} public void UpdateAuthorizedPerson(ref OperationResult pobjOperationResult, authorizedpersonDto pobjDtoEntity, List <string> ClientSession) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); // Obtener la entidad fuente var objEntitySource = (from a in dbContext.authorizedperson where a.v_AuthorizedPersonId == pobjDtoEntity.v_AuthorizedPersonId select a).FirstOrDefault(); // Crear la entidad con los datos actualizados pobjDtoEntity.d_UpdateDate = DateTime.Now; pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]); authorizedperson objEntity = authorizedpersonAssembler.ToEntity(pobjDtoEntity); // Copiar los valores desde la entidad actualizada a la Entidad Fuente dbContext.authorizedperson.ApplyCurrentValues(objEntity); // Guardar los cambios dbContext.SaveChanges(); pobjOperationResult.Success = 1; // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "PERSONAS AUTORIZADAS", "v_AuthorizedPersonId=" + objEntity.v_AuthorizedPersonId.ToString(), Success.Ok, null); return; } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex); // Llenar entidad Log LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "PERSONAS AUTORIZADAS", "v_AuthorizedPersonId=" + pobjDtoEntity.v_AuthorizedPersonId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage); return; } }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="authorizedperson"/> converted from <see cref="authorizedpersonDto"/>.</param> static partial void OnEntity(this authorizedpersonDto dto, authorizedperson entity);
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="authorizedpersonDto"/> converted from <see cref="authorizedperson"/>.</param> static partial void OnDTO(this authorizedperson entity, authorizedpersonDto dto);