Exemplo n.º 1
0
        //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;
            }
        }